6👍
The actual problem came out was…
The error was related more to Django internals in combination with the MSAL library.
Azure AD MSAL library for Python uses reverse(redirect_uri)
method internally to build the redirect uri somewhere inside and since Django requests use HTTP internally, the redirect uri, that gets added to the request, is the HTTP one.
Solution
Adding SECURE_SSL_REDIRECT = True
to settings.py
fixed the problem.
Although the ordinary ./manage.py runserver
command does not support HTTPS, so
pip install werkzeug django-extensions pyOpenSSL
- Add
django_extensions
under setting.pyINSTALLED_APPS
- Run server with
./manage.py runserver_plus --cert /tmp/cert localhost:8000
When the program runs in a web server with front proxy, add this line as well, to not change the original request returned by backend:
In settings.py -> SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
0👍
This error can typically be caused by 2 different configuration issues.
(1) accessing the page from a different address than what you’ve configured for your app.
(2) you have made a mistake in the configuration itself. In both of these cases, it’s typically fairly easy to fix the issue.
It seems the error occurs with the configuration in your issue.
Please notice the redirect_uri
parameter if requesting /token
endpoint for access token, the redirect_uri needs to be same as one of the Redirect URIs (navigate to your app -> Authentication) in the portal. If using C#, you also need to set it in the configuration.
- [Django]-Docker-compose can't import Django (ModuleNotFoundError)
- [Django]-Haystack Faceted: __init__() got an unexpected keyword argument 'facet_fields'
- [Django]-Facebook Signed Request Decoding Incorrect Padding
- [Django]-How to create an object for a model from the console similar to how Django made the createsuperuser command
- [Django]-Passing an object in every Django page