0

I used scribe to connect to google using oAuth 2.0 and successfully got the access token. When i am trying to get the blogs i always get the below error

Unauthorized Must authenticate to use 'default' user

Below is the code snippet

GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthConsumerKey(CONSUMER_KEY);
oauthParameters.setOAuthConsumerSecret(CONSUMER_SECRET_KEY);
oauthParameters.setScope("http://www.blogger.com/feeds");
oauthParameters.setOAuthToken(ACCESS_TOKEN);
oauthParameters.setOAuthTokenSecret(ACCESS_TOKEN_SECRET); // this is null 

BloggerService myService = new BloggerService("blogger");
try {           
myService.setOAuthCredentials(oauthParameters, new OAuthHmacSha1Signer());          
} catch (OAuthException e) {
e.printStackTrace();
}
final URL feedUrl = new URL("http://www.blogger.com/feeds/default/blogs");
Query query = new Query(feedUrl);
Feed resultFeed = myService.getFeed(query, Feed.class);

Not able to get the feeds here and displays the Unauthorized error as mentioned above.

Sanket
  • 612
  • 5
  • 23
  • You appear to be using OAuth 1.0 in your code, not 2.0. – Jason Hall Jan 30 '13 at 06:16
  • I have got the access token while connecting through scribe using oAuth2.0 , how to get the blogs using oAuth 2.0 ? – Sanket Jan 30 '13 at 07:04
  • You may want to use the Blogger v3 API described here: https://developers.google.com/blogger/docs/3.0/getting_started -- Java library here: https://code.google.com/p/google-api-java-client/wiki/APIs#Blogger_API – Jason Hall Jan 30 '13 at 14:50

1 Answers1

0

Jason has answered your question, I believe.

You do not want to use the library code above to access blogger. Use the new API, and use OAuth2 https://developers.google.com/blogger/docs/3.0/using#auth

I'm not sure what scribe is, but with OAuth2, you need to indicate what type of application you're building, It might be one that runs from a web server, or an installed application. What's you've determined that, you can follow the appropriate documentation for the java client library linked to above to get the access token and retrieve the data.

David Primmer
  • 421
  • 2
  • 7