gpt4 book ai didi

django-rest-auth 通过访问 token 进行谷歌社交身份验证

转载 作者:行者123 更新时间:2023-12-04 14:21:20 28 4
gpt4 key购买 nike

我正在使用 django-rest-auth 通过 API 进行社交身份验证。我已经配置了 Facebook,它运行良好,但我在使用 Google 社交身份验证时遇到了一些问题。

  1. 我已经添加到 INSTALLED_APPS:
allauth.socialaccount.providers.google',
  1. 创建的 View :

from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
from allauth.socialaccount.providers.oauth2.client import OAuth2Client

class CustomGoogleOAuth2Adapter(GoogleOAuth2Adapter):
basic_auth = False


class GoogleLogin(SocialLoginView):
adapter_class = CustomGoogleOAuth2Adapter
client_class = OAuth2Client
  1. 由管理面板创建应用
  2. 我从 https://developers.google.com/oauthplayground/ 得到了 access_token
  3. 当我尝试通过端点登录时出现错误:
Reverse for 'redirect' not found. 'redirect' is not a valid view function or pattern name.

最佳答案

很难查明错误,因为您没有包含其余代码。该错误仅表示它找不到名称为“redirect”的 url。因此,您可以检查两件事:

urlpatterns = [
...,
url(r'^rest-auth/', include('rest_auth.urls'))
]

Under “APIs & auth” go to “Credentials” and create a new Client ID. Probably you will want a “Web application” Client ID. Provide your domain name or test domain name in “Authorized JavaScript origins”. Finally fill in http://127.0.0.1:8000/accounts/google/login/callback/ in the “Authorized redirect URI” field. You can fill multiple URLs, one for each test domain. After creating the Client ID you will find all details for the Django configuration on this page.

关于django-rest-auth 通过访问 token 进行谷歌社交身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54479789/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com