Java – Google Reader API authentication
•
Java
I'm trying to use this snippet to authenticate on Google API services:
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");
Now I have tokens like dqaai... Kz6ol8kb56_ Afnfc (more than 100 characters long) and try to get the web address:
URL url = new URL(LIKERS_URL + "?i=" + id);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.addRequestProperty("Authorization","GoogleLogin Auth=" + token);
return url;
But when I use this URL to get content, I get 401 client error exception What can it be?
According to this problem, everything should be OK
I can simply paste the content into the browser
Solution
Try using OAuth for Google Reader authentication / authorization You only need to use OAuth library and register your application with Google to obtain OAuth user key / key
You can use OAuth googlecode. Com or scribe
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
