I have been trying to migrate a web app from Flask to react, and I had trouble getting a valid access token. In Flask, I used adal and had following codes:
authority_host_uri = 'https://login.microsoftonline.com'
tenant = '<my tenant id>'
authority_uri = authority_host_uri + '/' + tenant
resource_uri = 'https://management.core.windows.net/'
client_id = '<my client id>'
client_secret = '<my client secret>'
context = adal.AuthenticationContext(authority_uri, api_version=None)
mgmt_token = context.acquire_token_with_client_credentials(resource_uri, client_id, client_secret)
and the response was
{'tokenType': 'Bearer',
'expiresIn': 3599,
'expiresOn': '2020-05-27 18:22:07.128189',
'resource': 'https://management.core.windows.net/',
'accessToken':'<the access token that was needed>'
'isMRRT': True,
'_clientId': '<client id info>',
'_authority': '<authority above>'}
However, while I was trying to implement the same thing in msal in React, the access token that I got from
const tokenRequest = {
scopes: [clientId + "/user_impersonation"]
};
const response = await myMSALObj.acquireTokenSilent(tokenRequest)
was not valid, like it will get a 403 error from Azure catalog API, as the access token I got from Flask worked just fine. Are there different types of access token or is it because of the scoping? Is it possible to do the exact same thing as adal did in Flask (like no need to specify the scope, just using client secret to get the right access key? )