Skip to content

Commit

Permalink
Corrected CertificateAppCredentials scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tracy Boehrer committed Jul 2, 2024
1 parent 3ff2509 commit d2990d8
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def __init__(
oauth_scope=oauth_scope,
)

self.scopes = [self.oauth_scope]
self.app = None
self.certificate_thumbprint = certificate_thumbprint
self.certificate_private_key = certificate_private_key
Expand All @@ -56,16 +55,21 @@ def get_access_token(self, force_refresh: bool = False) -> str:
:return: The access token for the given certificate.
"""

scope = self.oauth_scope
if not scope.endswith("/.default"):
scope += "/.default"
scopes = [scope]

# Firstly, looks up a token from cache
# Since we are looking for token for the current app, NOT for an end user,
# notice we give account parameter as None.
auth_token = self.__get_msal_app().acquire_token_silent(
self.scopes, account=None
scopes, account=None
)
if not auth_token:
# No suitable token exists in cache. Let's get a new one from AAD.
auth_token = self.__get_msal_app().acquire_token_for_client(
scopes=self.scopes
scopes=scopes
)
return auth_token["access_token"]

Expand Down

0 comments on commit d2990d8

Please sign in to comment.