IByUsernameAndPassword.AcquireTokenByUsernamePassword Method

Definition

Acquires a token without user interaction using username and password authentication. This method does not look in the token cache, but stores the result in it. Before calling this method, use other methods such as AcquireTokenSilent(IEnumerable<String>, IAccount) to check the token cache.

public Microsoft.Identity.Client.AcquireTokenByUsernameAndPasswordConfidentialParameterBuilder AcquireTokenByUsernamePassword (System.Collections.Generic.IEnumerable<string> scopes, string username, string password);
abstract member AcquireTokenByUsernamePassword : seq<string> * string * string -> Microsoft.Identity.Client.AcquireTokenByUsernameAndPasswordConfidentialParameterBuilder
Public Function AcquireTokenByUsernamePassword (scopes As IEnumerable(Of String), username As String, password As String) As AcquireTokenByUsernameAndPasswordConfidentialParameterBuilder

Parameters

scopes
IEnumerable<String>

Scopes requested to access a protected API.

username
String

Identifier of the user, application requests token on behalf of. Generally in UserPrincipalName (UPN) format, e.g. john.doe@contoso.com

password
String

User password as a string.

Returns

A builder enabling you to add optional parameters before executing the token request.

Remarks

Available only for .NET Framework and .NET Core applications. See our documentation for details.

Applies to