0

スクライブを使用して oAuth 2.0 を使用して Google に接続し、アクセス トークンを取得しました。ブログを取得しようとすると、常に以下のエラーが発生します

「デフォルト」ユーザーを使用するには認証が必要です

以下はコードスニペットです

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);

ここでフィードを取得できず、前述のように Unauthorized エラーが表示されます。

4

1 に答える 1

0

ジェイソンがあなたの質問に答えたと思います。

上記のライブラリ コードを使用して Blogger にアクセスする必要はありません。新しい API を使用し、OAuth2 を使用します https://developers.google.com/blogger/docs/3.0/using#auth

スクライブが何であるかはわかりませんが、OAuth2 では、構築しているアプリケーションの種類を示す必要があります。それは、Web サーバーから実行されるアプリケーションか、インストールされたアプリケーションである可能性があります。上記にリンクされている Java クライアント ライブラリの適切なドキュメントに従って、アクセス トークンを取得し、データを取得できます。

于 2013-02-01T23:04:36.623 に答える