Retrieve blog feeds using google oauth 2.0 and scribe

﹥>﹥吖頭↗ 提交于 2020-01-06 07:28:10

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/14589152/retrieve-blog-feeds-using-google-oauth-2-0-and-scribe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!