question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Azure Active Directory b2c] authentication failed due to: jwt audience is invalid

See original GitHub issue

When I use the sample, all steps refer to this document.https://docs.microsoft.com/en-us/azure/active-directory-b2c/tutorial-single-page-app-webapi?tabs=app-reg-ga

An error occurred when I called the public API after logging in with my B2C account.

{"name":"AzureAD: Bearer Strategy","hostname":"jerry7","pid":1968,"level":30,"msg":"authentication failed due to: jwt audience is invalid","time":"2020-07-31T09:30:39.544Z","v":0}
GET /hello 401 5196.990 ms - -

This is the configuration of my web api sample.

const clientID = "9fe10508-405d-4617-8dee-52bca87e202f"; // Application (client) ID of your API's application registration
const b2cDomainHost = "poadevadb2c.b2clogin.com";
const tenantId = "poadevadb2c.onmicrosoft.com"; // Alternatively, you can use your Directory (tenant) ID (a GUID)
const policyName = "B2C_1_dpoa-b2c";

I’m sure all my Azure configurations are correct, but I can’t figure out where the problem is.

Hope to get help, thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
imxushuai-docscommented, Aug 5, 2020

I configured the application separately for the web api, but I did not use its client id correctly. thank you for your help

0reactions
imxushuai-docscommented, Aug 5, 2020

I should know where the error happened.

Read more comments on GitHub >

github_iconTop Results From Across the Web

asp.net web api - Azure AAD - The audience is invalid
"aud" value that is being generated for JWT token by azure is also controlled by "accessTokenAcceptedVersion" property in AD application ...
Read more >
Active Directory Authenticate API Application using Token ...
I would like to pass this JWT token to API App and get authenticated. ... Bearer error="invalid_token", error_description="The audience ...
Read more >
Azure AD Authentication 401 error "the audience is invalid ...
jQuery : Azure AD Authentication 401 error "the audience is invalid " AddAzureADBearer .Net Core Web Api [ Beautify Your Computer ...
Read more >
invalid jwt audience when running the sample #293 - GitHub
authentication failed due to: In _validateResponse: jwt audience is invalid. expected: 000000004C1CEE64,spn:000000004C1CEE64 .
Read more >
Azure AD Sign-in Error 50027 - Invalid JWT token
Invalid JWT token due to the following reasons: doesn't contain nonce claim, sub claim subject identifier mismatch duplicate claim in idToken claims ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found