Hi, Though you retrieved a token from the session and sent to obtain an access token, it is a request token. To abtain an access token, you need to send an authorized request token. Your consumer site should have received already it from Google OAuth provider as query parameter of the callback. So you can rerieve it via a request object of GET handler of sevlet.
On 1月29日, 午後9:43, setu <[email protected]> wrote: > I am developing a Java Application where I am implementing 3-legged OAuth > using google gdata in Java. At the first stage, I am getting the > request-token successfully. I am storing that token in session. Now I am > sending request to fetch Access Token. My code is : > > GoogleOAuthParameters oauthParameters = new > GoogleOAuthParameters(); > oauthParameters.setOAuthConsumerKey(CONSUMER_KEY); > oauthParameters.setOAuthConsumerSecret(CONSUMER_SECRET); > GoogleOAuthHelper oauthHelper = new GoogleOAuthHelper(new > OAuthHmacSha1Signer()); > > oauthParameters.setOAuthToken(request.getSession().getAttribute("oauth_toke > n").toString()); > > oauthParameters.setOAuthTokenSecret(request.getSession().getAttribute("oaut > h_token_secret").toString()); > > String url = oauthHelper.getAccessTokenUrl(); > > try { > System.out.print("Access Token : " + > oauthHelper.getAccessToken(url ,oauthParameters)); > } catch (OAuthException e) { > System.out.print("Response Status : " + > response.getStatus()); > System.out.print("Exception : "); > e.printStackTrace(); > return; > } > > But, I am getting the response that is : > > INFO: Response Status : 200 > INFO: Exception : > SEVERE: com.google.gdata.client.authn.oauth.OAuthException: oauth_token does > not exist. > at > com.google.gdata.client.authn.oauth.OAuthParameters.assertExists(OAuthParam > eters.java:612) > at > com.google.gdata.client.authn.oauth.OAuthParameters.assertOAuthTokenExists( > OAuthParameters.java:387) > at > com.google.gdata.client.authn.oauth.OAuthHelper.getAccessToken(OAuthHelper. > java:549) > at > com.google.gdata.client.authn.oauth.OAuthHelper.getAccessToken(OAuthHelper. > java:511) > > For sure, I have set the oauth_token & oauth_token_secret in the session. > But, still I don't know where am I getting wrong :(
