wagnerdelima / drf-social-oauth2

drf-social-oauth2 makes it easy to integrate Django social authentication with major OAuth2 providers, i.e., Facebook, Twitter, Google, etc.
https://drf-social-oauth2.readthedocs.io/en/latest/
MIT License
271 stars 34 forks source link

Google oauth2 no longer provides access token but the idToken #159

Closed MehdiDRISSIB closed 1 year ago

MehdiDRISSIB commented 1 year ago

Hello @wagnerdelima

google provide only id_token and no longer accesstoken which is expected in your library

I'm using the api convert-token for google login. Google provide now only the id_token as it's explained here: https://developers.google.com/identity/sign-in/web/backend-auth?hl=en the api convert-token throws error: "Your credentials aren't allowed" because of this. All my credentials are correct except this one. Please fix the issue. Many thanks in advance

FYI: @SukiCZ @PrasanthPerumalsamy

Hexvortex commented 1 year ago

yeah am also facing same issue

Hexvortex commented 1 year ago

@MehdiDRISSIB Have you any solution or work around?

MehdiDRISSIB commented 1 year ago

Here is a proposed solution but I didn't test it yet. If you do, please give a feedback and the whole code. I'm still waiting for a fix on this library

wagnerdelima commented 1 year ago

@MehdiDRISSIB how can I get the id token from google playground (https://developers.google.com/oauthplayground/)? It still gives me the access token. So it's hard to implement the feature. Thanks.

SukiCZ commented 1 year ago

@wagnerdelima You can obtain the id_token in Google Identity Service which is the recommended way for new APIs.

wagnerdelima commented 1 year ago

@SukiCZ and @MehdiDRISSIB this answer works. However, there is a little configuring you need to do.

First of all, add the code from the link in this file drf_social_oauth2/backends.py, like so:

image

The in your settings, replace the green by the blue one. This is the new class you just created.

image

In your request, replace google-oauth2 backend by google-identity. image

Send the request and success!

I can't make a fix right now because I have to further my studies on this. Soon I will provide a solution with a release tag.

SukiCZ commented 1 year ago

@wagnerdelima I believe this issue is more related to social-core and new "Google Identity Service Backend" should be provided there. It has a lot in common with previous Google Plus Backend. This is related - https://github.com/python-social-auth/social-core/pull/710

wagnerdelima commented 1 year ago

@SukiCZ yes I understand. But we don't need to submit a correction to social core, we can make it here.

MehdiDRISSIB commented 1 year ago

Hello

I just tried the solution of @wagnerdelima and it works very well. Many thanks !

We are waiting for the solution in the new release

wagnerdelima commented 1 year ago

Hi @SukiCZ , @MehdiDRISSIB, @Hexvortex and @vbabiy,

I just publish a new release with the fixes. Thanks for contributing!