/// <summary> /// [V3 API] Attempts to acquire an access token for the <paramref name="account"/> from the user token cache. /// See https://aka.ms/msal-net-acquiretokensilent for more details /// </summary> /// <param name="scopes">Scopes requested to access a protected API</param> /// <param name="account">Account for which the token is requested.</param> /// <returns>An <see cref="AcquireTokenSilentParameterBuilder"/> used to build the token request, adding optional /// parameters</returns> /// <exception cref="MsalUiRequiredException">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</exception> /// <remarks> /// The access token is considered a match if it contains <b>at least</b> 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: /// <see cref="AbstractAcquireTokenParameterBuilder{T}.WithAuthority(string, bool)"/> or one of its /// overrides to request a token for a different authority than the one set at the application construction /// <see cref="AcquireTokenSilentParameterBuilder.WithForceRefresh(bool)"/> to bypass the user token cache and /// force refreshing the token, as well as /// <see cref="AbstractAcquireTokenParameterBuilder{T}.WithExtraQueryParameters(Dictionary{string, string})"/> to /// specify extra query parameters /// /// </remarks> public AcquireTokenSilentParameterBuilder AcquireTokenSilent(IEnumerable <string> scopes, IAccount account) { return(AcquireTokenSilentParameterBuilder.Create( ClientExecutorFactory.CreateClientApplicationBaseExecutor(this), scopes, account)); }
AcquireTokenByRefreshTokenParameterBuilder IByRefreshToken.AcquireTokenByRefreshToken( IEnumerable <string> scopes, string refreshToken) { return(AcquireTokenByRefreshTokenParameterBuilder.Create( ClientExecutorFactory.CreateClientApplicationBaseExecutor(this), scopes, refreshToken)); }
/// <summary> /// [V3 API] Attempts to acquire an access token for the <see cref="IAccount"/> /// having the <see cref="IAccount.Username" /> match the given <paramref name="loginHint"/>, from the user token cache. /// See https://aka.ms/msal-net-acquiretokensilent for more details /// </summary> /// <param name="scopes">Scopes requested to access a protected API</param> /// <param name="loginHint">Typically the username, in UPN format, e.g. [email protected] </param> /// <returns>An <see cref="AcquireTokenSilentParameterBuilder"/> used to build the token request, adding optional /// parameters</returns> /// <exception cref="MsalUiRequiredException">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</exception> /// <remarks> /// If multiple <see cref="IAccount"/> match the <paramref name="loginHint"/>, or if there are no matches, an exception is thrown. /// /// The access token is considered a match if it contains <b>at least</b> 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: /// <see cref="AbstractAcquireTokenParameterBuilder{T}.WithAuthority(string, bool)"/> or one of its /// overrides to request a token for a different authority than the one set at the application construction /// <see cref="AcquireTokenSilentParameterBuilder.WithForceRefresh(bool)"/> to bypass the user token cache and /// force refreshing the token, as well as /// <see cref="AbstractAcquireTokenParameterBuilder{T}.WithExtraQueryParameters(Dictionary{string, string})"/> to /// specify extra query parameters /// /// </remarks> public AcquireTokenSilentParameterBuilder AcquireTokenSilent(IEnumerable <string> scopes, string loginHint) { if (string.IsNullOrWhiteSpace(loginHint)) { throw new ArgumentNullException(nameof(loginHint)); } return(AcquireTokenSilentParameterBuilder.Create( ClientExecutorFactory.CreateClientApplicationBaseExecutor(this), scopes, loginHint)); }