Microsoft backend "argument of type 'NoneType' is not iterable"
richardARPANET opened this issue · 1 comments
richardARPANET commented
Expected behaviour
Login should complete.
Actual behaviour
Login fails to "complete", TypeError
exception raises, server returns 500.
social-auth-app-django==4.0.0
social-auth-core==4.4.2
What are the steps to reproduce this issue?
I have no idea, this only happens sometimes for some users.
Any logs, error output, etc?
TypeError
argument of type 'NoneType' is not iterable
social_core/backends/microsoft.py in get_user_details at line 46
def get_user_details(self, response):
"""Return user details from Microsoft online account"""
email = response.get("mail")
username = response.get("userPrincipalName")
if "@" in username:
if not email:
email = username
username = username.split("@", 1)[0]
The exception occurs on this line if "@" in username:
, only sometimes.
Here is the data from response
var pulled from Sentry:
{
@odata.context: 'https://graph.microsoft.com/v1.0/$metadata#users/$entity',
access_token: REDACTED,
displayName: None,
expires_in: 3600, ext_expires_in: 3600, id: 'd785c8deb228b9a8',
refresh_token: REDACTED,
scope: 'User.Read Files.ReadWrite',
token_type: 'Bearer', userPrincipalName: None
}
richardARPANET commented
Suggests this should never be null/none? 🤔