I am trying to authenticate on google api service using this 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 I have token like: DQAAAI...kz6Ol8Kb56_afnFc (more than 100 chars length) and try to get url:
URL url = new URL(LIKERS_URL + "?i=" + id);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.addRequestProperty("Authorization", "GoogleLogin Auth=" + token);
return url;
But while I am getting content using this url I get 401 Client Error exception. What can it be?
According to this question http://stackoverflow.com/questions/3100078/google-reader-authentication-problem all should be fine.
I can get the content simply pasting the url into browser.