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");

An application instance can only deal with one cloud. If your app needs to handle multiple clouds at the same time, please create an app for each of them.

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