【发布时间】:2011-06-23 23:04:20
【问题描述】:
我正在使用 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: 好的 未知 授权标头
未知 授权头
错误 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) 在 com.google.gdata.client.Service.getFeed(Service.java:1017) 在 Oauth.accessFeeds.access(accessFeeds.java:74)
这有什么问题?
【问题讨论】:
标签: java oauth request-headers