问题描述
我有Djang + React项目,我需要使用Google OAuth2对用户登录进行身份验证.看起来social-auth-app-django
是用于Django的流行软件包,我在搜索如何使用它.
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.
但是我在前端没有找到任何关于React的例子.我可以看到很多示例,这些示例都由Djang模板实现,就像这样.
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>
但是使用React Login
按钮应该指向什么呢?我应该将React的Google OAuth2 Key或Google OAuth2 Secret传递给Django吗?
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?
需要帮助,谢谢!
推荐答案
如果您想在react中使用Google OAuth2,那么react-google-login
是一个很好的软件包.
If you want to use Google OAuth2 in react, react-google-login
is a good package.
这篇关于在项目上使用social-auth-app-django的Google Auth(Django + React)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!