diff --git a/zproject/backends.py b/zproject/backends.py index d7ae8c28ba..ff27c2a497 100644 --- a/zproject/backends.py +++ b/zproject/backends.py @@ -2229,6 +2229,15 @@ class GitHubAuthBackend(SocialAuthMixin, GithubOAuth2): @external_auth_method class AzureADAuthBackend(SocialAuthMixin, AzureADOAuth2): + # The upstream implementation uses the outdated /oauth2/authorize + # API (instead of the v2.0 API), which doesn't allow us to authenticate + # users with just a personal Microsoft account. v2.0 API is required. + # This requires us to override the default URLs to use it as well + # as adjust the requested scopes, to match this new API. + AUTHORIZATION_URL = "{base_url}/oauth2/v2.0/authorize" + ACCESS_TOKEN_URL = "{base_url}/oauth2/v2.0/token" + DEFAULT_SCOPE = ["User.Read profile openid email"] + sort_order = 50 name = "azuread-oauth2" auth_backend_name = "AzureAD"