Skip to content

Commit

Permalink
Add AzureADOauth2 backend using the v2.0 API.
Browse files Browse the repository at this point in the history
AzureADOAuth2 uses the v1.0 API which doesn't support personal accounts.
Updating the endpoints used by the original class may break backward
compatibility, so add this as just an additional subclass.
  • Loading branch information
mateuszmandera authored and nijel committed Sep 2, 2024
1 parent 19ae97d commit d9554fa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions social_core/backends/azuread.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,14 @@ def get_auth_token(self, user_id):
new_token_response = self.refresh_token(token=access_token)
access_token = new_token_response["access_token"]
return access_token


class AzureADOAuth2V2(AzureADOAuth2):
"""Version of the AzureADOAuth2 backend that uses the v2.0 API endpoints,
supporting users with personal Microsoft accounts, if the app settings
allow them."""

name = "azuread-oauth2-v2"
AUTHORIZATION_URL = "{base_url}/oauth2/v2.0/authorize"
ACCESS_TOKEN_URL = "{base_url}/oauth2/v2.0/token"
DEFAULT_SCOPE = ["User.Read profile openid email"]

0 comments on commit d9554fa

Please sign in to comment.