Partilhar via


PublicClientApplication.AcquireTokenByUsernamePassword Method

Definition

Overloads

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

Non-interactive request to acquire a security token from the authority, via Username/Password Authentication. See https://aka.ms/msal-net-up for details.

AcquireTokenByUsernamePassword(IEnumerable<String>, String, String)

Non-interactive request to acquire a security token from the authority, via Username/Password Authentication. See https://aka.ms/msal-net-up for details.

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 security token from the authority, via Username/Password Authentication. See https://aka.ms/msal-net-up for details.

[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
override this.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

Implements

Attributes

Remarks

You can also pass optional parameters by chaining the builder with: Microsoft.Identity.Client.AbstractAcquireTokenParameterBuilder`1.WithExtraQueryParameters(System.Collections.Generic.Dictionary{System.String,System.String}) to pass additional query parameters to the STS, and one of the overrides of WithAuthority(String, Boolean) in order to override the default authority set at the application construction. Note that the overriding authority needs to be part of the known authorities added to the application construction. .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.

Applies to

AcquireTokenByUsernamePassword(IEnumerable<String>, String, String)

Non-interactive request to acquire a security token from the authority, via Username/Password Authentication. See https://aka.ms/msal-net-up for details.

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
override this.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

Implements

Remarks

You can also pass optional parameters by chaining the builder with: Microsoft.Identity.Client.AbstractAcquireTokenParameterBuilder`1.WithExtraQueryParameters(System.Collections.Generic.Dictionary{System.String,System.String}) to pass additional query parameters to the Azure AD, and one of the overrides of WithAuthority(String, Boolean) in order to override the default authority set at the application construction. Note that the overriding authority needs to be part of the known authorities added to the application construction.

Applies to