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

Django and react login with google #645

Open
AREEG94FAHAD opened this issue Jul 17, 2021 · 2 comments
Open

Django and react login with google #645

AREEG94FAHAD opened this issue Jul 17, 2021 · 2 comments

Comments

@AREEG94FAHAD
Copy link

AREEG94FAHAD commented Jul 17, 2021

I am trying to use Django rest auth with react login with google.

backend
In my views.py file

class GoogleLogin(SocialLoginView):
    adapter_class = GoogleOAuth2Adapter

In urls.py

path('rest-auth/google/', GoogleLogin.as_view(), name='google_login')

I also configured the database with google credentials

Front part

In authapt.js

const googleLogin = async (accesstoken,code) => {
    const res = await axios.post(
      "http://localhost:8000/rest-auth/google/",
      {
        access_token: accesstoken,
        code
        
      }
    );
    console.log(res);
    return  res.status;
  };

In Logincomponent.jsx

<GoogleLogin
          clientId="clientId"
          buttonText="LOGIN WITH GOOGLE"
          onSuccess={googleLogin  }
          onFailure={googleLogin}
        /> 

but when I try to log in with my google account I got POST http://localhost:8000/rest-auth/google/ 400 (Bad Request)
I want to save the user in the database of social account of backend any idea

@mateokurti
Copy link

I don't think this repo is taking any update. I suggest you to take a look at https://github.com/iMerica/dj-rest-auth

@najiib49
Copy link

najiib49 commented Oct 26, 2021

@AREEG94FAHAD I've implemented following the same steps and I'm getting same error where I can't save it to the database. Were you able to solve it?

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

3 participants