1

I am accessing Google Spreadsheet feeds using HMAC-SH1 sign. My Code is :

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

But, I am getting the error :

Oauth.requestServlet doGet: null com.google.gdata.util.AuthenticationException: OK Unknown authorization header

Unknown authorization header

Error 401

at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:600) at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563) at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552) at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530) at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535) at com.google.gdata.client.Service.getFeed(Service.java:1135) at com.google.gdata.client.Service.getFeed(Service.java:998) at 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)

What is the problem with this ?

2 Answers2

0

I suspect that the server is sending a "401 Unauthorized" response with a WWW-Authenticate header that the client code doesn't recognize. It may even be sending no WWW-Authenticate header at all ... vide the "null" in the exception message.

(The latter is a violation of the HTTP 1.1 specification. A 401 response is required to have a WWW-Authenticate header that the client uses to decide how to authenticate. Refer to the spec for details.)


So why might this be happening talking to a Google feed? Perhaps you've configured your client with the wrong URL? Perhaps your client is trying to connect via some poorly designed proxy?

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • As per it specified here : http://www.checkupdown.com/status/E401.html, I have authorized client & also I am logged in. –  Feb 09 '11 at 07:44
  • Wrong URL again not possible as I have registered this application online on GAE ! Even the scope & Feed URL I am specifying is correct & working ! –  Feb 09 '11 at 07:48
  • Well, I'm stumped. Perhaps you should use wireshark or something like that to see what the HTTP request and response really contain. The other thing you could do is plough through the Google search hits for this error. – Stephen C Feb 09 '11 at 08:04
  • Oh ! Surprising that from a complete new project, it works ! But, here the access token is in session from the start. While in this application I am fetching the Access Token from Google Datastore, which was stored previously ! –  Feb 09 '11 at 08:11
  • That one more problem with Google Jump currently still unsolved is this : http://stackoverflow.com/questions/4921523/userservice-getcurrentuser-returns-null –  Feb 09 '11 at 08:12
0

See Android Google Calendar Authorization Problem. Google is doing something different with the calendar feeds, redirecting with a new 'gsessionid' parameter in the querystring; may be the same problem with spreadsheet.

Community
  • 1
  • 1
jcomeau_ictx
  • 37,688
  • 6
  • 92
  • 107