I keep getting a AuthenticationFailed
error with a InvalidAuthenticationTokenAudience
inner error when attempting to query the /environments endpoint.
I have already created an app in the Azure Active Directory, given it access in the time series insights management portal and I can already get an Oauth 2.0 Access token from the auth URL.
I have tried giving the token url the 'https://api.timeseries.azure.com/' resource/audience/scope but the API keeps returning the same error message:
{ "error": { "code": "AuthenticationFailed", "message": "Server failed to authenticate the request. The token has been obtained from wrong audience or resource.", "innerError": { "code": "InvalidAuthenticationTokenAudience", "message": "The access token has been obtained from wrong audience or resource '00000002-0000-0000-c000-000000000000'. It should exactly match (including forward slash) with one of the allowed audiences 'https://api.timeseries.azure.com/'." } } }
I'm using Postman with the Oauth 2.0 authentication type, the client credentials Grant Type and send as basic Auth Header option for the token request.
Has anyone tried this with success?
Update 01:
The decoded (using JWT as suggested in comments) payload
portion of one of the tokens shows the that the aud
field is 00000002-0000-0000-c000-000000000000
. Which is definitely wrong.
Based on the exception, it indicates that the resource is not matching
https://api.timeseries.azure.com/
when acquire the access token.So please make sure that the resource is
https://api.timeseries.azure.com/
, for more information please refer to the screenshot.Get access token
I test Get environments API, it works correctly for me.