Search code examples
azureazure-active-directoryazure-storageazure-blob-storageazure-authentication

Azure Storage Authentication failing - Audience validation failed. Audience did not match. [AZURE][OAuth]


I am trying to make a REST call to Azure Storage using the following code. enter image description here

But It shows following error:

<?xml version="1.0" encoding="UTF-8"?>
<Error>
   <Code>AuthenticationFailed</Code>
   <Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\n' +
        'RequestId:11c07be7-301e-0003-556f-42091d000000\n' +
        'Time:2021-05-06T11:59:40.1049759Z</Message>
   <AuthenticationErrorDetail>Audience validation failed. Audience did not match.</AuthenticationErrorDetail>
</Error>

I have already assigned roles: enter image description here

And have API permissions set: enter image description here

But still this error. Can anyone help?


Solution

  • The audience of your access token is not correct. The aud(audience) should look like https://xxxx.blob.core.windows.net.

    Make sure the scope is https://{account-name}.blob.core.windows.net/user_impersonation when requesting for access token.

    enter image description here