Compartilhar via


IPublicClientApplication.AcquireTokenByUsernamePassword Method

Definition

Overloads

AcquireTokenByUsernamePassword(IEnumerable<String>, String, String)

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.

AcquireTokenByUsernamePassword(IEnumerable<String>, String, SecureString)
Obsolete.

Non-interactive request to acquire a token via username and password authentication.

AcquireTokenByUsernamePassword(IEnumerable<String>, String, String)

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.AcquireTokenByUsernamePasswordParameterBuilder AcquireTokenByUsernamePassword (System.Collections.Generic.IEnumerable<string> scopes, string username, string password);
abstract member AcquireTokenByUsernamePassword : seq<string> * string * string -> Microsoft.Identity.Client.AcquireTokenByUsernamePasswordParameterBuilder
Public Function AcquireTokenByUsernamePassword (scopes As IEnumerable(Of String), username As String, password As String) As AcquireTokenByUsernamePasswordParameterBuilder

Parameters

scopes
IEnumerable<String>

Scopes requested to access a protected API.

username
String

Identifier of the user application requests token on behalf. 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

AcquireTokenByUsernamePassword(IEnumerable<String>, String, SecureString)

Caution

Using SecureString is not recommended. Use AcquireTokenByUsernamePassword(IEnumerable<string> scopes, string username, string password) instead.

Non-interactive request to acquire a token via username and password authentication.

[System.Obsolete("Using SecureString is not recommended. Use AcquireTokenByUsernamePassword(IEnumerable<string> scopes, string username, string password) instead.", false)]
public Microsoft.Identity.Client.AcquireTokenByUsernamePasswordParameterBuilder AcquireTokenByUsernamePassword (System.Collections.Generic.IEnumerable<string> scopes, string username, System.Security.SecureString password);
[<System.Obsolete("Using SecureString is not recommended. Use AcquireTokenByUsernamePassword(IEnumerable<string> scopes, string username, string password) instead.", false)>]
abstract member AcquireTokenByUsernamePassword : seq<string> * string * System.Security.SecureString -> Microsoft.Identity.Client.AcquireTokenByUsernamePasswordParameterBuilder
Public Function AcquireTokenByUsernamePassword (scopes As IEnumerable(Of String), username As String, password As SecureString) As AcquireTokenByUsernamePasswordParameterBuilder

Parameters

scopes
IEnumerable<String>

Scopes requested to access a protected API

username
String

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

password
SecureString

User password as a secure string.

Returns

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

Attributes

Remarks

Available only for .NET Framework and .NET Core applications. See our documentation for details. .NET no longer recommends using SecureString and MSAL puts the plaintext value of the password on the wire, as required by the OAuth protocol. See SecureString documentation for details.

Applies to