我正在尝试使用此代码段在 google api 服务上进行身份验证:
RestTemplate restTemplate = new RestTemplate();
List<HttpMessageConverter<?>> converters =
new ArrayList<HttpMessageConverter<?>> restTemplate.getMessageConverters());
converters.add(new PropertiesHttpMessageConverter());
restTemplate.setMessageConverters(converters);
Properties result = preparePostTo(AUTHENTICATION_URL)
.using(restTemplate)
.expecting(Properties.class)
.withParam("accountType", "HOSTED_OR_GOOGLE")
.withParam("Email", email)
.withParam("Passwd", password)
.withParam("service", "reader")
.withParam("source", "google-like-filter")
.execute();
String token = (String) result.get("Auth");
现在我有这样的令牌:DQAAAI...kz6Ol8Kb56_afnFc(超过 100 个字符长度)并尝试获取 url:
URL url = new URL(LIKERS_URL + "?i=" + id);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.addRequestProperty("Authorization", "GoogleLogin Auth=" + token);
return url;
但是,当我使用此 url 获取内容时,我得到 401 Client Error 异常。会是什么?
根据这个问题谷歌阅读器身份验证问题应该没问题。
我只需将 url 粘贴到浏览器中即可获取内容。