Exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException

Yash Gupta 0 Reputation points
2024-06-03T17:22:28.5233333+00:00

After getting the token from oauth2 v2.0/token from i am trying to get https:/{name}.sharepoint.com/_api/Lists/getbytitle('listname') but getting an error

error_description:Exception of type Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException was thrown.

also i am passing

Header

Accept:application/json;odata=verbose

Content-Type:application/json;odata=verbose

Authorization:Bearer please tell what i am doing wrong

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
4,325 questions
Microsoft Authenticator
Microsoft Authenticator
A Microsoft app for iOS and Android devices that enables authentication with two-factor verification, phone sign-in, and code generation.
6,090 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,384 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,052 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 40,141 Reputation points
    2024-06-04T10:01:26+00:00

    Hi @Yash Gupta

    Make sure your scope value is set to https://{tenant-name}.sharepoint.com/.default.

    Here is an example call:

    User's image

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.