www-authenticate: Bearer error="invalid_token",error_description="The signature is invalid"

Mohamad Usman Sagri 6 Reputation points
2022-10-08T08:26:56.203+00:00

Hi,

I am trying to use my ad token at web api and getting following error

www-authenticate: Bearer error="invalid_token",error_description="The signature is invalid"
248550-image.png

I have added below configurations to my appsettings.json

"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"ClientId": "810c70dc-df08-4172-93ac-XXXXXX",
"TenantId": "7d6b867e-d1c6-4378-8c59-XXXXXXX"
}

and below authentication scheme to my program.cs

builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd"));

Kindly guide how to resolve this issue.

Developer technologies ASP.NET ASP.NET Core
Microsoft Security Microsoft Entra Microsoft Entra ID
{count} vote

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2022-10-08T16:44:12.803+00:00

    Also for webapi, in azure ad you need to define a scope and api access for azure ad application. The client request for access token should include this scope.

    1 person found this answer helpful.
    0 comments No comments

  2. Vinodh247 34,661 Reputation points MVP Volunteer Moderator
    2022-10-08T10:02:12.633+00:00

    Hi

    Thanks for reaching out to Microsoft Q&A.

    These are accepted answers for the same error earlier, please check -one of these should work for you.

    https://stackoverflow.com/questions/48944697/bearer-error-invalid-token-error-description-the-signature-is-invalid
    https://learn.microsoft.com/en-us/answers/questions/762957/www-authenticate-bearer-error34invalid-token34-err.html

    Please Upvote and Accept as answer if the reply was helpful, this will be helpful to other community members.

    0 comments No comments

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.