Skip to content

Authority Override

Bogdan Gavril edited this page Jun 9, 2021 · 6 revisions

In many scenarios, such as https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/Multi-tenant-client_credential-use, it is useful to specify the AAD tenant at the request level instead of the app level. However, the app and the request must always the same cloud, i.e. the host of the authority URL must not be different.

var app =  ConfidentialClientApplicationBuilder
                .Create(PublicCloudConfidentialClientID)
                .WithAuthority("https://login.microsoft.com/common", true)
                .Build();

var result = await app.AcquireTokenForClient(scopes)
                      .WithAuthority("https://login.microsoft.com/123456-1234-2345-1234561234");

Getting started with MSAL.NET

Acquiring tokens

Web Apps / Web APIs / daemon apps

Desktop/Mobile apps

Advanced topics

FAQ

Other resources

Clone this wiki locally