401 Unauthorized after creating client context using Access Token

Prateek Srivastava 1 Reputation point
2021-07-12T06:33:32.477+00:00

Hi,

I have a web application deployed to Azure and registered as App Registration with AAD authentication configured.

I am getting current users info as "ClaimsPrincipal.Current" and access token as Request.Headers["x-ms-id-aad-token"].

However when try to send the above access token to authorization header in client context and try to get current user, it throws 401 unauthorized

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,702 questions
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.
2,977 questions
{count} votes

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.