[英]Python Social Auth for Django raises Authforbidden exception
[英]Python social auth “AuthForbidden”
我正在嘗試使用social-auth與django一起使用google身份驗證,到目前為止我還沒有任何運氣。 其他帶有類似錯誤消息的問題表明,這可能是由列入白名單引起的,但是我想接受我應用中的所有gmail后綴。 (無需白名單)
INSTALLED_APPS = [
'livereload', # TODO Remove when finished
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dashboard.apps.DashboardConfig',
'user.apps.UserConfig',
'social_django'
]
'social_django.context_processors.backends'
和'social_django.context_processors.login_redirect'
都在我的上下文處理器中的settings.py中。
AUTHENTICATION_BACKENDS = (
'social_core.backends.open_id.OpenIdAuth', # for Google authentication
'social_core.backends.google.GoogleOpenId', # for Google authentication
'social_core.backends.google.GoogleOAuth2', # for Google authentication
'django.contrib.auth.backends.ModelBackend',
)
urlpatterns = [
path('dashboard/', include("dashboard.urls", namespace="dashboard")),
path('admin/', admin.site.urls),
path('login/', auth_views.LoginView.as_view(), name="login"),
path('logout/', auth_views.LogoutView.as_view(), name="logout"),
path('auth/', include("social_django.urls", namespace="social")),
]
當我使用google登錄並重定向到我的身份驗證網址時,我收到以下消息:
AuthForbidden at /auth/complete/google-oauth2/
Your credentials aren't allowed
我該如何使其正常工作?
編輯:我一直在瀏覽錯誤消息,並發現這,如果這對任何人都有幫助。
http_error_msg = ('401 Client Error: Unauthorized for url: 'https://accounts.google.com/o/oauth2/token')
reason = 'Unauthorized'
self = <Response [401]>
經過數天的故障排除后,歸結為一些我應該更加關注的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.