Redirect URI error with Google social login in dj-rest-auth

29 Views Asked by At

I try to add a google login button to my website, that runs django as the server. For social authentication I want use dj-rest-auth and tried to go according to it's guides to authenticate with google auth-code flow.

On the client side I use the @react-oauth/google package. The setup on my django server is this:

views.py
class GoogleLogin(SocialLoginView):
  adapter_class = GoogleOAuth2Adapter
  callback_url = "http://127.0.0.1:8000/accounts/google/login/callback/"
  client_class = OAuth2Client

urls.py
path("auth/google/", GoogleLogin.as_view(), name="google_login"),

The google credentials screen settings:

js origins redirect URIs

Whenever I try to login with google I get an 400 error from the dj-rest-auth view, and when I debugged the code I looked at the response from google(https://oauth2.googleapis.com/token): I get the following error in the response text(also 400)

{ "error": "redirect_uri_mismatch", "error_description": "Bad Request" }

It looks like my server send the correct redirect uri in the payload enter image description here

Any help or tips with this issue and social auth in general would be very appreciated, thank you.

0

There are 0 best solutions below