Azure AD by default generates Application URI in below format.
api://<<Client_Id>>
but When you change Application URI with "https://xyz.onmicrosoft.com/<<Client_Id>>" and the token generated using Auth Code Grant or Client Credential flow, if passed to API for Authorization, you will get below error.
WWW-Authenticate: Bearer error="invalid_token", error_description="The audience ‘https://xyz.onmicrosoft.com/<<Client_Id>>’ is invalid"
2
Answers
To solve this, AppSettings should be added as mentioned below,
Note: If you are using default URI then Audience is not required but with custom Application URI, Audience needs to be added.
In my application config file I had to set Audience to Application ID URI (api://myapp.com) and when fetching a token in Insomnia resource had to be set TO the same Application ID URI