user1625971
user1625971

Reputation: 499

How to set callback URL for Google OAuth?

I am using Google OAuth to authenticate the user in my GAE application. After the user clicks on "Grant Access", I want to return to my application. I tried setting the callback URL, but instead of being called independently, it gets appended to the current URL in the browser, and thus shows as an invalid URL.

Here is my code:

 OAuthGetTemporaryToken requestToken = new OAuthGetTemporaryToken(REQUEST_TOKEN_URL);
        requestToken.consumerKey = CONSUMER_KEY;
        requestToken.transport = TRANSPORT;
        requestToken.signer = signer;
        requestToken.callback="www.mail.yahoo.com";

        OAuthCredentialsResponse requestTokenResponse = requestToken.execute();

        // updates signer's token shared secret
        signer.tokenSharedSecret = requestTokenResponse.tokenSecret;

        OAuthAuthorizeTemporaryTokenUrl authorizeUrl = new OAuthAuthorizeTemporaryTokenUrl(AUTHORIZE_URL);
        authorizeUrl.temporaryToken = requestTokenResponse.token;

This line sends it to the Google OAuth page.

resp.sendRedirect(authorizeUrl.build());

I have set the callback parameter as shown above, but it's not working. Please help! Thanks in advance.

Upvotes: 7

Views: 43373

Answers (1)

Tim Bray
Tim Bray

Reputation: 1663

This is OAuth1 stuff, which is deprecated. Try using OAuth 2.0 instead. Start at https://developers.google.com/accounts/docs/OAuth2

Upvotes: 6

Related Questions