drf-social-oauth2 icon indicating copy to clipboard operation
drf-social-oauth2 copied to clipboard

Google oauth2

Open PrasanthPerumalsamy opened this issue 3 years ago • 1 comments
trafficstars

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...

PrasanthPerumalsamy avatar Aug 16 '22 12:08 PrasanthPerumalsamy

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

SukiCZ avatar Sep 14 '22 19:09 SukiCZ

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

MehdiDRISSIB avatar Mar 14 '23 03:03 MehdiDRISSIB

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

SukiCZ avatar Mar 14 '23 09:03 SukiCZ

@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

MehdiDRISSIB avatar Mar 14 '23 16:03 MehdiDRISSIB

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.

wagnerdelima avatar Mar 26 '23 13:03 wagnerdelima