A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
Hi @Anonymous ,
I'm glad to hear you solve the problem ,if you have any issue about SharePoint, you are welcome to raise a ticket in this forum.
By the way, since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others." and according to the scenario introduced here: Answering your own questions on Microsoft Q&A, I would make a brief summary of this thread:
[Getting Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException when attempting to retrieve 'lists' in Sharepoint Online API]
Issue Symptom:
I registered Sharepoint App in Azure and retrieved a ClientId, Secret, and accessing the Tenant. I'm successfully now retrieving an Access_Token...
After retrieving this Access_token, I'm attempting to run https://<ourUrl>.sharepoint.com/_api/lists and including that token in the Authorization header. I'm getting the following error code... 401 Unauthorized - {"error_description":"Exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException' was thrown."}
Solutions:
1.Input the URL: https://xxx.sharepoint.com/sites/xxx/_api/site/id in browser to get the site-id.
2.Move permissions from delegated to application.(Get SharePoint Lists need the following permissions : Sites.Read.All, Sites.ReadWrite.All.)
3.Using Graph API to get lists should run: GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/ ,and include the Access_token in the Authorization header.
You could click the "Accept Answer" button for this summary to close this thread, and this can make it easier for other community member's to see the useful information when reading this thread. Thanks for your understanding!
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.