Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft backend "argument of type 'NoneType' is not iterable" #840

Open
richardARPANET opened this issue Oct 15, 2023 · 1 comment
Open

Comments

@richardARPANET
Copy link

richardARPANET commented Oct 15, 2023

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
}

image

@richardARPANET
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant