Revert account selecton

This commit is contained in:
2024-06-24 22:00:47 +02:00
parent 86278c360f
commit e4b064bb6c

View File

@@ -30,17 +30,15 @@ app = msal.ConfidentialClientApplication(
# You can learn how to use SerializableTokenCache from
# https:#msal-python.readthedocs.io/en/latest/#msal.SerializableTokenCache
)
accounts = app.get_accounts(username=None)
def get_access_token():
global app, token, accounts
global app, token
# The pattern to acquire a token looks like this.
# 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.
token = app.acquire_token_silent(MsalConfig.SCOPE, account=accounts[0])
token = app.acquire_token_silent(MsalConfig.SCOPE, account=None)
if token is None:
logging.info("No suitable token exists in cache. Let's get a new one from AAD.")