I’m integrating Microsoft Entra ID with my web app using OAuth2 for a dedicated app registration specific to my tenant. Despite setting the accessTokenAcceptedVersion
in the manifest to 2
, I am still receiving access tokens with version 1. This issue is hindering my ability to validate and use the tokens as required.
Here’s how I’m initiating the OAuth2 authorization:
https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/authorize?scope=openid+profile+email&response_type=code&client_id={client-id}&redirect_uri={redirect-uri}&state={state}&code_challenge={code-challenge}&code_challenge_method=S256
After obtaining the authorization code, I exchange it for a token at the token v2 endpoint (I double-checked that). However, the access token I receive continues to be version 1 and the aud
is set to 00000003-0000-0000-c000-000000000000
which seems to be Microsoft Graph. The ID token seems to be version 2.
Has anyone encountered this issue before? How can I ensure that my application receives the specified version 2 tokens? Any help or suggestions would be greatly appreciated.
2
Answers
As some mentioned in the comments, setting accepted token version only affects tokens intended for your API.
If you get an MS Graph API token, it respects the settings that MS Graph has defined, not the ones you define.
You need to add a scope under Expose an API page and request for that when authenticating.
Initially, I modified
accessTokenAcceptedVersion
value to 2 in Manifest of app registration like this:Now I generated access token with Microsoft Graph scope via Postman with below parameters:
Response:
When I decoded this token in jwt.ms website, access token has 1.0 as version with aud as
00000003-0000-0000-c000-000000000000
:In my case, I exposed an API and created new scope named
test.scope
as below:To get the
code
value, I ran below authorization URL by replacing scope value withapi://appID/test.scope
:Now, I used this
code
to generate access token via Postman with scope as Exposed API value like this:Response:
When I decoded this token in jwt.ms website, access token has 2.0 as version: