Compartir a través de


ClientApplicationBase.AcquireTokenSilent Method

Definition

Overloads

AcquireTokenSilent(IEnumerable<String>, IAccount)

[V3 API] Attempts to acquire an access token for the account from the user token cache. See https://aka.ms/msal-net-acquiretokensilent for more details

AcquireTokenSilent(IEnumerable<String>, String)

[V3 API] Attempts to acquire an access token for the IAccount having the Username match the given loginHint, from the user token cache. See https://aka.ms/msal-net-acquiretokensilent for more details

AcquireTokenSilent(IEnumerable<String>, IAccount)

[V3 API] Attempts to acquire an access token for the account from the user token cache. See https://aka.ms/msal-net-acquiretokensilent for more details

public Microsoft.Identity.Client.AcquireTokenSilentParameterBuilder AcquireTokenSilent (System.Collections.Generic.IEnumerable<string> scopes, Microsoft.Identity.Client.IAccount account);
abstract member AcquireTokenSilent : seq<string> * Microsoft.Identity.Client.IAccount -> Microsoft.Identity.Client.AcquireTokenSilentParameterBuilder
override this.AcquireTokenSilent : seq<string> * Microsoft.Identity.Client.IAccount -> Microsoft.Identity.Client.AcquireTokenSilentParameterBuilder
Public Function AcquireTokenSilent (scopes As IEnumerable(Of String), account As IAccount) As AcquireTokenSilentParameterBuilder

Parameters

scopes
IEnumerable<String>

Scopes requested to access a protected API

account
IAccount

Account for which the token is requested.

Returns

An AcquireTokenSilentParameterBuilder used to build the token request, adding optional parameters

Implements

Exceptions

will be thrown in the case where an interaction is required with the end user of the application, for instance, if no refresh token was in the cache, or the user needs to consent, or re-sign-in (for instance if the password expired), or the user needs to perform two factor authentication

Remarks

The access token is considered a match if it contains at least all the requested scopes. This means that an access token with more scopes than requested could be returned. If the access token is expired or close to expiration - within a 5 minute window - then the cached refresh token (if available) is used to acquire a new access token by making a silent network call.

You can set additional parameters by chaining the builder with: WithTenantId(String) to request a token for a different authority than the one set at the application construction WithForceRefresh(Boolean) to bypass the user token cache and force refreshing the token, as well as Microsoft.Identity.Client.AbstractAcquireTokenParameterBuilder`1.WithExtraQueryParameters(System.Collections.Generic.Dictionary{System.String,System.String}) to specify extra query parameters

Applies to

AcquireTokenSilent(IEnumerable<String>, String)

[V3 API] Attempts to acquire an access token for the IAccount having the Username match the given loginHint, from the user token cache. See https://aka.ms/msal-net-acquiretokensilent for more details

public Microsoft.Identity.Client.AcquireTokenSilentParameterBuilder AcquireTokenSilent (System.Collections.Generic.IEnumerable<string> scopes, string loginHint);
abstract member AcquireTokenSilent : seq<string> * string -> Microsoft.Identity.Client.AcquireTokenSilentParameterBuilder
override this.AcquireTokenSilent : seq<string> * string -> Microsoft.Identity.Client.AcquireTokenSilentParameterBuilder
Public Function AcquireTokenSilent (scopes As IEnumerable(Of String), loginHint As String) As AcquireTokenSilentParameterBuilder

Parameters

scopes
IEnumerable<String>

Scopes requested to access a protected API

loginHint
String

Typically the username, in UPN format, e.g. johnd@contoso.com

Returns

An AcquireTokenSilentParameterBuilder used to build the token request, adding optional parameters

Implements

Exceptions

will be thrown in the case where an interaction is required with the end user of the application, for instance, if no refresh token was in the cache, or the user needs to consent, or re-sign-in (for instance if the password expired), or the user needs to perform two factor authentication

Remarks

If multiple IAccount match the loginHint, or if there are no matches, an exception is thrown.

The access token is considered a match if it contains at least all the requested scopes. This means that an access token with more scopes than requested could be returned. If the access token is expired or close to expiration - within a 5 minute window - then the cached refresh token (if available) is used to acquire a new access token by making a silent network call.

You can set additional parameters by chaining the builder with: WithTenantId(String) to request a token for a different authority than the one set at the application construction WithForceRefresh(Boolean) to bypass the user token cache and force refreshing the token, as well as Microsoft.Identity.Client.AbstractAcquireTokenParameterBuilder`1.WithExtraQueryParameters(System.Collections.Generic.Dictionary{System.String,System.String}) to specify extra query parameters

Applies to