You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用social-auth-app-django集成Okta OIDC时遇Backend not found及404错误

使用social-auth-app-django 5.4.2搭建Okta OIDC登录的问题

我在使用social-auth-app-django 5.4.2搭建Okta OIDC登录功能时,遇到了“Backend not found”错误及404页面未找到问题。

已完成的配置

  • 已将social_django添加至INSTALLED_APPS
  • 已将social_django.middleware.SocialAuthExceptionMiddleware添加至MIDDLEWARE
  • 已将social_django.context_processors.backends和social_django.context_processors.login_redirect添加至TEMPLATES['OPTIONS']['context_processors']列表

核心配置代码

AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.ModelBackend', 
    'social_core.backends.okta_openidconnect.OktaOpenIdConnect',
]

LOGIN_URL = 'auth/login/okta_openidconnect/'

URL配置

path('auth/', include('social_django.urls', namespace='social'))

错误信息

访问登录URL时出现404,错误详情:

Backend not found
Request Method: GET
Request URL:    https://my.site/auth/login/okta_openidconnect/?next=/en-us/
Raised by:  social_django.views.auth

Using the URLconf defined in xxx.urls, Django tried these URL patterns, in this order:
...
17. en-us/ auth/ login/<str:backend>/ [name='begin']
The current path, en-us/auth/login/okta_openidconnect/, matched the last one.

我确认SOCIAL_AUTH_OKTA_OPENIDCONNECT_KEY及SOCIAL_AUTH_PIPELINE等配置正确,且认为这些与后端未找到问题无关。请问我的配置中是否存在导致该问题的错误?


编辑补充

我意识到登录URL需使用连字符而非下划线,将:

LOGIN_URL = 'auth/login/okta_openidconnect/'

修改为:

LOGIN_URL = 'auth/login/okta-openidconnect/'

后,可跳转至Okta,但出现了新的“Okta页面未找到”错误。


内容的提问来源于stack exchange,提问作者anp925

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 04:08:12