1

HMAC-SH1 記号を使用して Google スプレッドシート フィードにアクセスしています。私のコードは:

GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
        oauthParameters.setOAuthConsumerKey(CONSUMER_KEY);
        oauthParameters.setOAuthConsumerSecret(CONSUMER_SECRET);
        oauthParameters.setScope("https://spreadsheets.google.com/feeds/");
        oauthParameters.setOAuthType(OAuthParameters.OAuthType.THREE_LEGGED_OAUTH);
        oauthParameters.setOAuthToken(request.getSession().getAttribute("oauth_token").toString());
        oauthParameters.setOAuthTokenSecret(request.getSession().getAttribute("oauth_token_secret").toString());

GoogleService googleService = new GoogleService("wise", "searceapps-searcegadget2-1");
        googleService.setOAuthCredentials(oauthParameters, new OAuthHmacSha1Signer());
        URL feedUrl = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full/");

        SpreadsheetFeed resultFeed = googleService.getFeed(feedUrl, SpreadsheetFeed.class);

しかし、私はエラーが発生しています:

Oauth.requestServlet doGet: null com.google.gdata.util.AuthenticationException: OK 不明な認証ヘッダー

不明な承認ヘッダー

エラー 401

com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:600) で com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563) で com.google.gdata.client. .http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552) com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530) com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest) .java:535) com.google.gdata.client.Service.getFeed(Service.java:1135) com.google.gdata.client.Service.getFeed(Service.java:998) com.google.gdata で。 client.GoogleService.getFeed(GoogleService.java:631) at com.google.gdata.client.Service.getFeed(Service.java:1017) at Oauth.accessFeeds.access(accessFeeds.java:74)

これの問題は何ですか?

4

2 に答える 2

0

Android Google カレンダー認証の問題を参照してください。Google は、カレンダー フィードで別のことを行っており、クエリ文字列に新しい「gsessionid」パラメーターを使用してリダイレクトしています。スプレッドシートと同じ問題かもしれません。

于 2011-04-26T00:28:00.910 に答える
0

サーバーが、クライアント コードが認識しないWWW-Authenticateヘッダーを含む "401 Unauthorized" 応答を送信していると思われます。WWW-Authenticate ヘッダーをまったく送信していない可能性もあります...例外メッセージの「null」を確認してください。

(後者は HTTP 1.1 仕様に違反しています。401 応答には、クライアントが認証方法を決定するために使用する WWW-Authenticate ヘッダーが必要です。詳細については、仕様を参照してください。)


では、なぜこれが Google フィードに話しかけているのでしょうか? 間違った URL でクライアントを構成した可能性がありますか? おそらく、クライアントは、設計が不十分なプロキシを介して接続しようとしていますか?

于 2011-02-09T07:36:30.067 に答える