AbstractAcquireTokenParameterBuilder<T>.WithTenantIdFromAuthority Method

Definition

Extracts the tenant ID from the provided authority URI and overrides the tenant ID specified in the authority at the application level. This operation preserves the authority host (environment) provided to the application builder. If an authority was not provided to the application builder, this method will replace the tenant ID in the default authority - https://login.microsoftonline.com/common.

public T WithTenantIdFromAuthority (Uri authorityUri);
member this.WithTenantIdFromAuthority : Uri -> 'T
Public Function WithTenantIdFromAuthority (authorityUri As Uri) As T

Parameters

authorityUri
Uri

URI from which to extract the tenant ID

Returns

T

The builder to chain the .With methods.

Exceptions

Thrown if authorityUri is null or an empty string.

Thrown if authorityUri is not well-formatted (for example, has spaces).

Thrown in general exception scenarios (for example if the application was configured with an authority that does not allow tenants).

Remarks

The tenant should be more restrictive than the one configured at the application level, e.g. don't use "common". Does not affect authority validation, which is specified at the application level.

Applies to