java - Google Reader API Authentication -
i trying authenticate on google api service using snippet:
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 have token like: dqaaai...kz6ol8kb56_afnfc (more 100 chars length) , try url:
url url = new url(likers_url + "?i=" + id); httpurlconnection connection = (httpurlconnection)url.openconnection(); connection.addrequestproperty("authorization", "googlelogin auth=" + token); return url;
but while getting content using url 401 client error exception. can be?
according question google reader authentication problem should fine.
i can content pasting url browser.
try using oauth google reader authentication/authorization. need use oauth library , register app google oauth consumer key/secret.
you can use oauth.googlecode.com or scribe.
Comments
Post a Comment