TemplateDoesNotExist at /oauth2/callback
See original GitHub issueI am getting this error after sending the user to log in with AD and then sending it back to the app.
I have set up the @login_required attribute on the index function in the views.py.
I have added the adfs URLs to the views here:
urlpatterns = [
path('oauth2/', include('django_auth_adfs.urls')),
path('', views.home, name='home'),
path('contact/', views.contact, name='contact'),
path('about/', views.about, name='about'),
path('testpage/', views.testpage, name='testpage'),
path('login/',
LoginView.as_view
(
template_name='app/login.html',
authentication_form=forms.BootstrapAuthenticationForm,
extra_context=
{
'title': 'Log in',
'year' : datetime.now().year,
}
),
name='login'),
path('logout/', LogoutView.as_view(next_page='/'), name='logout'),
path('admin/', admin.site.urls),
]
Here are my templates:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
And my middleware:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware'
#'django_auth_adfs.middleware.LoginRequiredMiddleware'
]
ROOT_URLCONF = 'DjangoWebProject1.urls'
The login required line was commented out due to it causing errors on launch.
I also added a template under templates/app/oauth2/callback.html and it does not resolve properly.
Any insight on this is appreciated.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Login failed issue · Issue #143 · snok/django-auth-adfs - GitHub
When i login via adfs and the user does not exists in django users table i get login failed , also in my...
Read more >TemplateDoesNotExist at /users/profile - django - Stack Overflow
I am trying to make a profile page, which simply is a page with user details, such as firstname, lastname, email, etc. But...
Read more >django-auth-adfs - bytemeta
TemplateDoesNotExist at /oauth2/callback ... Make software development more efficient, Also welcome to join our telegram.
Read more >How to resolve Django TemplateDoesNotExist Error on ...
This video will show you how to resolve Django TemplateDoesNotExist Error on Windows machine.
Read more >Django Part 1 - TemplateDoesNotExist - Code with Mosh Forum
I tried Stackoverflow's solutions, but it didn't seem to help. Below is the output of the error when I go to http://localhost:8000/playground/ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t have the time to really investigate this until next week, but yes, a example repo is a good way to get help. You also have a demo project in this repository here.
I’d recommend you take a step back and ensure that you have the authentication backends installed, the login required middleware is enabled again, and that your redirect URL from ADFS/Azure is correct.
Enable debug to get all the logs.
You’ve also got a new issue now compared to before, so search the previous issues for similar errors. This answer might help you.
You can close out this issue. I was able to resolve it by adding it to the installed apps.
The error afterwards was resolved by updating my reply url to oauth/login.
Hopefully this helps anyone else.