Google Auth using social-auth-app-django on project(Django + React)
Asked Answered
I

1

2

I have project with Djang + React and I need using Google OAuth2 to authenticate user login. Looks like social-auth-app-django is popular package to use for Django, and I had a search on how to use it.

But I could not find any example with React on frontend. I can see a lot of examples with a button implemented by Djang templates like this.

 <a class="btn btn-primary" href="{% url 'social:begin' 'google-oauth2' %}">
    Login
 </a>

But what it should be pointing to with a React Login button? And should I pass Google OAuth2 Key or Google OAuth2 Secret from React to Django?

NEED HELP, thanks!

Indignation answered 31/1, 2020 at 5:55 Comment(1)
Per this answer: While using <a href="{% url 'social:begin' 'google-plus' %}">Login</a> for login, it translates to /login/google-plus/. This not only get's the acess_token but also creates a "social user" in your database. May be that will point you in the right direction.Carlsen
O
0

If you want to use Google OAuth2 in react, react-google-login is a good package.

Osmanli answered 31/1, 2020 at 6:7 Comment(1)
I need authenticate user login status on server sideIndignation

© 2022 - 2024 — McMap. All rights reserved.