Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] B2C Invalid token, audience is invalid #1405

Closed
1 task done
RhomGit opened this issue Aug 25, 2021 · 4 comments
Closed
1 task done

[Question] B2C Invalid token, audience is invalid #1405

RhomGit opened this issue Aug 25, 2021 · 4 comments
Labels
question Further information is requested

Comments

@RhomGit
Copy link

RhomGit commented Aug 25, 2021

Which version of Microsoft Identity Web are you using?
Microsoft Identity Web 1.16.0

Where is the issue?

  • Web API
    • Protected web APIs (validating tokens)

Is this a new or an existing app?
c. This is a new app or an experiment.

I have a desktop App and I am trying to secure an API. Both API and App are registered in Azure.
jwt.ms reports that the audience in the token is the same as the one being reported by Postman as being incorrect:
Bearer error="invalid_token", error_description="The audience '89da34ef-desktop-app-id' is invalid"

image

image

Any idea why the audience is being reported as incorrect?

@RhomGit
Copy link
Author

RhomGit commented Aug 25, 2021

As per this doc https://github.com/AzureAD/microsoft-identity-web/wiki/web-apis I have updated ConfigureServices to just:
services.AddMicrosoftIdentityWebApiAuthentication(Configuration, "AzureAdB2C");

As per this doc https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-protected-web-api-app-registration I have checked and:
accessTokenAcceptedVersion = 2

I have triple-checked and the client app has access to the API:
image

@jmprieur jmprieur added the question Further information is requested label Aug 26, 2021
@jmprieur
Copy link
Collaborator

@RhomGit
What scopes are you asking in the client? (desktop app)?

@RhomGit
Copy link
Author

RhomGit commented Aug 26, 2021

Hi @jmprieur , thanks for your response.
image

Also for completeness the controller isn't checking scopes yet (commented out). I don't think the request actually hits the controller.
image

@RhomGit
Copy link
Author

RhomGit commented Aug 31, 2021

Update: after looking at jwt.ms I notice that MSAL isn't returning the scopes in the token.
I have no idea why this is.

I have raised a ticket here: AzureAD/microsoft-authentication-library-for-dotnet#2856

@RhomGit RhomGit closed this as completed Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants