wagnerdelima/drf-social-oauth2

Google oauth2

Closed this issue · 5 comments

google oauth2 not providing access tokens for newly created id's only providing id_token

here is the link https://developers.google.com/identity/sign-in/web/backend-auth

Please update the package...

Hi @PrasanthPerumalsamy
I was facing same issue and fixed that with a custom Backend that inherits from GooglePlusAuth.

from social_core.backends.google import GooglePlusAuth


class GoogleIdentityBackend(GooglePlusAuth):
    name = "google-identity"

    def user_data(self, access_token, *args, **kwargs):
        """Don't care about the `id_token`"""
        response = self.get_json(
            # https://oauth2.googleapis.com/tokeninfo
            "https://www.googleapis.com/oauth2/v3/tokeninfo",
            params={"id_token": access_token},
        )
        self.process_error(response)
        return response

I believe this issue is more related to python-social-core

I got the same issue. google provide only id_token and not accesstoken. Any help please @wagnerdelima
How to convert token in this case ? When I try to convert-token with id_token I got the error:

{"message":{"error":"access_denied","error_description":"Your credentials aren't allowed"}}

The credentials are corrects in my post request except the token

SukiCZ commented

@MehdiDRISSIB Have you tried customize the GooglePlusAuth? The customization I'd posted works for me.

@SukiCZ Many thanks for your feedback. As I use Facebook login also in my app which works well, I would like keep the same api for both which is convert-token.
If it's not fixed in the package, yes I would have to go through another way and probably try your view. I will give a feedback if I try your solution

Hi guys. I didn't understand the problem per se. I will close this issue and you can create another based on a template that makes it easier to understand.

Thanks.