/// <summary> /// Authenticates the user using the specified username and password. /// </summary> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns>The <see cref="AuthenticationRecord"/> of the authenticated account.</returns> public virtual async Task <AuthenticationRecord> AuthenticateAsync(CancellationToken cancellationToken = default) { // get the default scope for the authority, throw if no default scope exists string defaultScope = KnownAuthorityHosts.GetDefaultScope(_pipeline.AuthorityHost) ?? throw new CredentialUnavailableException(NoDefaultScopeMessage); return(await AuthenticateAsync(new TokenRequestContext(new string[] { defaultScope }), cancellationToken).ConfigureAwait(false)); }
/// <summary> /// Authenticates the user using the specified username and password. /// </summary> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns>The <see cref="AuthenticationRecord"/> of the authenticated account.</returns> public virtual AuthenticationRecord Authenticate(CancellationToken cancellationToken = default) { // get the default scope for the authority, throw if no default scope exists string defaultScope = KnownAuthorityHosts.GetDefaultScope(_pipeline.AuthorityHost) ?? throw new CredentialUnavailableException(NoDefaultScopeMessage); return(Authenticate(new TokenRequestContext(new string[] { defaultScope }), cancellationToken)); }