AngellusMortis / django_microsoft_auth

Simple app to enable Microsoft Account, Office 365 and Xbox Live authentcation as a Django authentcation backend.
MIT License
137 stars 84 forks source link

Failed to authenticate you for an unknown reason #450

Open tonisoler opened 3 years ago

tonisoler commented 3 years ago

Django Microsoft Authentication Backend version: 2.4.0 Django version: 3.1 Python version: 3.8 Operating System: Linux Browser and version: Chrome Description In django admin i get an error in user authentication with and generic error: Failed to authenticate you for an unknown reason.

With debug info i only see that: Apr 16, 2021 @ 17:03:13.096 {"asctime": "2021-04-16 17:03:13,096", "name": "django.request", "levelname": "WARNING", "pathname": "/python36/root/usr/lib/python3.6/site-packages/django/utils/log.py", "filename": "log.py", "funcName": "log_response", "lineno": 230, "message": "Bad Request: /microsoft/auth-callback/", "thread": 47168128110080, "status_code": 400, "request": "<WSGIRequest: POST '/microsoft/auth-callback/'>"} Apr 16, 2021 @ 17:03:13.090 {"asctime": "2021-04-16 17:03:13,089", "name": "django", "levelname": "WARNING", "pathname": "/python36/root/usr/lib/python3.6/site-packages/microsoft_auth/client.py", "filename": "client.py", "funcName": "get_claims", "lineno": 153, "message": "could verify id_token sig: It is required that you pass in a value for the \"algorithms\" argument when calling decode().", "thread": 47168128110080} Apr 16, 2021 @ 17:03:13.087 {"asctime": "2021-04-16 17:03:13,087", "name": "urllib3.connectionpool", "levelname": "DEBUG", "pathname": "/python36/root/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", "filename": "connectionpool.py", "funcName": "_make_request", "lineno": 442, "message": "https://login.microsoftonline.com:443 \"GET /XXXXxx/discovery/v2.0/keys HTTP/1.1\" 200 6330", "thread": 47168128110080} https://login.microsoftonline.com:443 "GET /XXXX/discovery/v2.0/keys HTTP/1.1" 200 6330 Apr 16, 2021 @ 17:03:13.007 {"asctime": "2021-04-16 17:03:13,006", "name": "requests_oauthlib.oauth2_session", "levelname": "DEBUG", "pathname": "/python36/root/usr/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", "filename": "oauth2_session.py", "funcName": "request", "lineno": 469, "message": "Invoking 0 protected resource request hooks.", "thread": 47168128110080} Invoking 0 protected resource request hooks. Apr 16, 2021 @ 17:03:13.007 {"asctime": "2021-04-16 17:03:13,006", "name": "requests_oauthlib.oauth2_session", "levelname": "DEBUG", "pathname": "/python36/root/usr/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", "filename": "oauth2_session.py", "funcName": "request", "lineno": 475, "message": "Adding token {'token_type': 'Bearer', 'scope': ['email', 'profile', 'openid', 'User.Read'], 'expires_in': 3599, 'ext_expires_in': 3599, 'access_token': 'ACCESS_TOKEN_CORRECT', 'id_token': 'ID_TOKEN', 'expires_at': 1618588992.0055645} to request.", "thread": 47168128110080}

Environment Setup Steps This is using Django on a Heroku app, it's pretty standard.

Steps to Reproduce Configure django application, and try microsoft login in admin page: The login in microsoft page end correctly, the popup close, and shows the error.

andrewbird2 commented 3 years ago

I had the same on a recent new deploy. Downgraded pyjwt from 2.0.1 to 1.7.1 and it worked.

ihelmer07 commented 3 years ago

I think this is related to issue #430 which isn't in the pip installed version yet.