加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – Google Reader API身份验证

发布时间:2020-12-15 02:21:59 所属栏目:Java 来源:网络整理
导读:我正在尝试使用此代码段在google api服务上进行身份验证: RestTemplate restTemplate = new RestTemplate();ListHttpMessageConverter? converters = new ArrayListHttpMessageConverter? restTemplate.getMessageConverters());converters.add(new Propert
我正在尝试使用此代码段在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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读