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

[Bug] WAM can't be used when requesting token for itself #4667

Open
marionoack opened this issue Mar 18, 2024 · 3 comments
Open

[Bug] WAM can't be used when requesting token for itself #4667

marionoack opened this issue Mar 18, 2024 · 3 comments

Comments

@marionoack
Copy link

Library version used

4.59

.NET version

Windows 11, Net 4.8, x64

Scenario

PublicClient - desktop app

Is this a new or an existing app?

This is a new app or experiment

Issue description and reproduction steps

Hello,

I create in Entra a simple application registration and configure redirect for desktop apps.
Then I define an application ID Uri and expose one scope (user and admin consent)
Then I add this scope into the API permissions for this app (no pre-consent).

If I try to acquire a token, I received the following error:

Fehlercode: CAA20002
Korrelations-ID: 13a2227f-xxxx-4726-b98c-f5144a5fb091
Zeitstempel: 2024-03-18T08:26:12Z
Weitere Informationen: https://www.microsoft.com/wamerrors
Servermeldung: AADSTS90009: Application '28c3605d-xxxx-4180-8dac-
e3ed534b93f3'(28c3605d-xxxx-4180-8dac-e3ed534b93f3) is requesting a
token for itself. This scenario is supported only if resource is specified using the
GUID based App Identifier. Trace ID: 0d0a3d5f-xxxx-4726-b775-e411dbdc0200
Correlation ID: 13a2227f-xxxx-4726-b98c-f5144a5fb091 Timestamp: 2024-03-
18 08:26:12Z

Then I removed "WithBroker" to use browser based login. All works fine, I receive a token.

Relevant code snippets

publicClientApp = PublicClientApplicationBuilder.Create(ClientId)
                      .WithDefaultRedirectUri()
                      .WithAuthority(AzureCloudInstance.AzurePublic, Tenant)
                      .WithParentActivityOrWindow(()=>window)
                      .WithBroker(new BrokerOptions(BrokerOptions.OperatingSystems.Windows))
                      .Build();
..
publicClientApp.AcquireTokenInteractive(listOfScopesToRequest)

Expected behavior

Login with or without broker should returns the same result. The error message is not helpful (and wrong?)

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

No response

Solution and workarounds

Adding the scope in Authorized client application fix the problem.

@marionoack marionoack added needs attention Delete label after triage untriaged Do not delete. Needed for Automation labels Mar 18, 2024
@bgavrilMS
Copy link
Member

If I understand correctly, you have a setup where the client needs to call a web api. You represented both using the same app registration. I believe WAM doesn't support this, and you'll need to create a separate app registration for your web api. Please try that.

@bgavrilMS bgavrilMS added bug P2 workaround exists WAM public-client and removed untriaged Do not delete. Needed for Automation needs attention Delete label after triage labels Mar 18, 2024
@marionoack
Copy link
Author

We try to authenticate and authorize only our app. Later on, this app-registration can add external scopes. But for today we use scope/token only for validation purpose of user account. So we see no need to register two applications (app and api) for one application.

If we disable the broker, it works! So we think, the broker has a problem.

Is there a better approach to use application registration for login purpose of a simple app?

@bgavrilMS
Copy link
Member

I agree @marionoack - this is a bug in the broker. However, I don't think this is a broker bug that will get fixed anytime soon.

To me, the security benefits that the broker providers outweigh maintaining 2 app registrations (one for client, one for web api).

It's really up to you - use browser based authN and 1 app reg or broker based authN and 2 app reg.

@pmaytak pmaytak changed the title [Bug] [Bug] WAM can't be used when requesting token for itself Mar 19, 2024
@localden localden added the broker label Apr 2, 2024
@localden localden self-assigned this May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants