java – Google Reader API身份验证
作者:互联网
我正在尝试使用此代码段在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 = new URL(LIKERS_URL + "?i=" + id);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.addRequestProperty("Authorization", "GoogleLogin Auth=" + token);
return url;
但是当我使用此URL获取内容时,我得到401客户端错误异常.它能是什么?
根据这个问题Google Reader Authentication problem一切都应该没问题.
我可以将内容简单地粘贴到浏览器中.
解决方法:
尝试使用OAuth进行Google Reader身份验证/授权.您只需使用OAuth库并向Google注册您的应用即可获取OAuth使用者密钥/密钥.
您可以使用oauth.googlecode.com或Scribe.
标签:java,authentication,google-reader 来源: https://codeday.me/bug/20190710/1421521.html