Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to use an idToken rather than an accessToken? #12

Open
dllabs opened this issue Mar 11, 2019 · 2 comments
Open

Question: How to use an idToken rather than an accessToken? #12

dllabs opened this issue Mar 11, 2019 · 2 comments

Comments

@dllabs
Copy link

dllabs commented Mar 11, 2019

Google's docs for Android-based OAUTH2 authentication say that we should send an idToken rather than an accessToken to our backend server.

How do you do that using Graphene Social Auth?

The only docs/examples I've found use access tokens. For instance:

mutation SocialAuth($provider: String!, $accessToken: String!) {
  socialAuth(provider: $provider, accessToken: $accessToken) {
    social {
      uid
      extraData
    }
  }
}

I imagine I can use Graphene Social Auth as is, by exchanging my idTokens for accessTokens in my Android client, but I'd rather do that server-side as Google recommends, just by sending in the idToken to the server and then have Graphene Social Auth exchange it for an accessToken and then do its stuff.

thanks!

John

@dllabs
Copy link
Author

dllabs commented Mar 11, 2019

I've figured out that the GooglePlus backend can work if I comment out the line in graphql_social_auth/social_core/backends/google.py that uses the accessToken, thereby forcing it to use the idToken instead, as follows:

def user_data(self, access_token, *args, **kwargs):
    # if 'id_token' not in self.data:
    #     return super(GooglePlusAuth, self).user_data(access_token, *args,
    #                                                  **kwargs)
    response = self.get_json(
        'https://www.googleapis.com/oauth2/v3/tokeninfo',
        params={'id_token': access_token}
    )
    self.process_error(response)
    return response

Better though would be to pass 'id_token' into self.data, so I don't have to comment out that line.
How do I get 'id_token' into self.data in a django-graphql-social-auth mutation?

cheers

John

@codalprashant
Copy link

any updates on the above issue mentioned ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants