title: how to authenticate to Azure time series insights query API?
body: <p>I keep getting a <code>AuthenticationFailed</code> error with a <code>InvalidAuthenticationTokenAudience</code> inner error when attempting to query the /environments endpoint.</p>
  
  <p>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.</p>
  
  <p>I have tried giving the token url the '<a href="https://api.timeseries.azure.com/" rel="nofollow noreferrer">https://api.timeseries.azure.com/</a>' resource/audience/scope but the API keeps returning the same error message:</p>
  
  <blockquote>
    <p>{
        "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 '<a href="https://api.timeseries.azure.com/" rel="nofollow noreferrer">https://api.timeseries.azure.com/</a>'."
            }
        } }</p>
  </blockquote>
  
  <p>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.</p>
  
  <p>Has anyone tried this with success?</p>
  
  <p>Update 01:
  The decoded (using JWT as suggested in comments) <code>payload</code> portion of one of the tokens shows the that the <code>aud</code> field is <code>00000002-0000-0000-c000-000000000000</code>. Which is definitely wrong.</p>