Skip to content

[Bug] TenantId Not Overridden in AcquireTokenInteractive When Using Public Client with WithTenantId #5258

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

Open
narendran-dev opened this issue Apr 28, 2025 · 1 comment
Labels
needs attention Delete label after triage Possible-Solution public-client Similar-Issue untriaged Do not delete. Needed for Automation

Comments

@narendran-dev
Copy link

Library version used

4.69.1.0

.NET version

.NET 8.0.8

Scenario

PublicClient - desktop app

Is this a new or an existing app?

The app is in production, I haven't upgraded MSAL, but started seeing this issue

Issue description and reproduction steps

When using the AcquireTokenInteractive method in MSAL.NET and passing the TenantId (either organisation or consumers), the expected behavior of overriding the tenant ID does not occur. The authentication flow defaults to the common tenant, even when a specific TenantId is passed during the interactive token acquisition.

Relevant code snippets

this._msalClient =  PublicClientApplicationBuilder .Create(authEndPointSetting.CommonEndPointClientId)
                                    .WithDefaultRedirectUri()
                                    .WithLegacyCacheCompatibility(false)
                                    .WithHttpClientFactory(new MsalHttpFactory())
                                    .Build();



            var authRequest = __msalClient.AcquireTokenInteractive(scopes)
                .WithLoginHint(userName)
                .WithUseEmbeddedWebView(isEmbeddedWebView)
                .WithTenantId(tenantId.ConvertToLoginTenantType());// based on the user’s email we will pass consumer or organisation or common.

Expected behavior

No response

Identity provider

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

Regression

No response

Solution and workarounds

No response

@narendran-dev narendran-dev added needs attention Delete label after triage untriaged Do not delete. Needed for Automation labels Apr 28, 2025
Copy link

Here are some similar issues that might help you. Please check if they can solve your problem.


Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)

Use a tenanted authority instead, i.e. https://login.microsoftonline.com/{tenantId}

Reference:

Powered by issue-sentinel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs attention Delete label after triage Possible-Solution public-client Similar-Issue untriaged Do not delete. Needed for Automation
Projects
None yet
Development

No branches or pull requests

1 participant