Getting Exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException' in Sharepoint API

Aman Singh 31 Reputation points
2022-03-09T04:19:52.893+00:00

Hi,

I am trying to run the sharepoint APIs to manage recycle bin items in sharepoint sites.

But I am getting this error message -

{"error_description":"Exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException' was thrown."}

Description for my request -

URL - https://######.sharepoint.com/_api/web/recyclebin

Headers :
Accept - application/json;odata=verbose
Authorization - Bearer {token}

What can be reason here?

Hope for a quick response.

Thanks
Aman

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,039 questions
{count} votes

2 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 36,171 Reputation points Microsoft Vendor
    2022-03-09T06:33:37.6+00:00

    Hi @Aman Singh ,
    AudienceUriValidationFailedException means you don't have the permission to the crud operation. Please check your steps to get AccessToken by following.
    Granting access using SharePoint App-Only
    https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs
    Then you can refer to following steps get AccessToken
    https://global-sharepoint.com/sharepoint-online/in-4-steps-access-sharepoint-online-data-using-postman-tool/

    The url should be like https://######.sharepoint.com/sites/***/_api/site/recyclebin
    181264-image.png

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



  2. Aman Singh 31 Reputation points
    2022-03-14T10:10:20.203+00:00

    Hi @RaytheonXie_MSFT

    Thanks for the response.

    I am able to do the auth process for Sharepoint APIs and execute them irrespective of some access related errors. We might be able to resolve them by updating the permissions from administrator.

    I will let you know, once any update is there.

    Regards
    Aman


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.