anp925
anp925

Reputation: 69

page not found error when using python social auth login for okta

I am getting a "Backend not found" error when trying to setup okta oidc login using social-auth-app-django 5.4.2

here are the settings: 'social_django' is added to INSTALLED_APPS 'social_django.middleware.SocialAuthExceptionMiddleware' is added to MIDDLEWARE "social_django.context_processors.backends" and "social_django.context_processors.login_redirect" are added to the list in TEMPLATES['OPTIONS']['context_processors']

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

LOGIN_URL = 'auth/login/okta_openidconnect/'

and in the list of project urls, this is added

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

when i go to the login url, I get a 404 page not found error

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.

there are other settings, like SOCIAL_AUTH_OKTA_OPENIDCONNECT_KEY and the SOCIAL_AUTH_PIPELINE, which i'm sure are correct and i believe that even if they were not correct, it's unrelated to not having the proper backend.

so does anyone see a mistake in this setup that could be causing the backend fail?

[EDIT] i realized that the login needs a dash not an underscore. changing

LOGIN_URL = 'auth/login/okta_openidconnect/'

to

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

gets me to okta, where i get a different Okta Page Not Found error ...

Upvotes: 0

Views: 25

Answers (1)

anp925
anp925

Reputation: 69

turns out you need the '/oauth2' at the end of the url in SOCIAL_AUTH_OKTA_OPENIDCONNECT_API_URL

Upvotes: 0

Related Questions