Class UsernamePasswordAuthenticationProvider
Authentication Provider that uses a Resource Owner Password Credentials (ROCP) credential flow
Inherited Members
Namespace: PnP.Core.Auth
Assembly: PnP.Core.Auth.dll
Syntax
public sealed class UsernamePasswordAuthenticationProvider : OAuthAuthenticationProvider, IAuthenticationProvider
Remarks
You can find further details about ROPC here: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc
Constructors
UsernamePasswordAuthenticationProvider(ILogger<OAuthAuthenticationProvider>, IMsalHttpClientFactory)
Public constructor leveraging DI to initialize the ILogger and IMsalHttpClientFactory interfaces
Declaration
public UsernamePasswordAuthenticationProvider(ILogger<OAuthAuthenticationProvider> logger, IMsalHttpClientFactory msalHttpClientFactory)
Parameters
|
ILogger<OAuthAuthenticationProvider>
logger
The instance of the logger service provided by DI |
|
IMsalHttpClientFactory
msalHttpClientFactory
The instance of the Msal Http Client Factory service provided by DI |
UsernamePasswordAuthenticationProvider(string, string, PnPCoreAuthenticationUsernamePasswordOptions)
Public constructor for external consumers of the library
Declaration
public UsernamePasswordAuthenticationProvider(string clientId, string tenantId, PnPCoreAuthenticationUsernamePasswordOptions options)
Parameters
|
string
clientId
The Client ID for the Authentication Provider |
|
string
tenantId
The Tenant ID for the Authentication Provider |
|
PnPCoreAuthenticationUsernamePasswordOptions
options
Options for the authentication provider |
UsernamePasswordAuthenticationProvider(string, string, string, SecureString)
Public constructor for external consumers of the library
Declaration
public UsernamePasswordAuthenticationProvider(string clientId, string tenantId, string username, SecureString password)
Parameters
|
string
clientId
The Client ID for the Authentication Provider |
|
string
tenantId
The Tenant ID for the Authentication Provider |
|
string
username
The Username for authentication |
|
SecureString
password
The Password for authentication |
Properties
Password
The password for authenticating
Declaration
public SecureString Password { get; set; }
Property Value
| SecureString |
Username
The username for authenticating
Declaration
public string Username { get; set; }
Property Value
| string |
Methods
AuthenticateRequestAsync(Uri, HttpRequestMessage)
Authenticates the specified request message.
Declaration
public override Task AuthenticateRequestAsync(Uri resource, HttpRequestMessage request)
Parameters
|
Uri
resource
Request uri |
|
HttpRequestMessage
request
The HttpRequestMessage to authenticate. |
Returns
|
Task
The task to await. |
Overrides
GetAccessTokenAsync(Uri)
Gets an access token for the requested resource
Declaration
public override Task<string> GetAccessTokenAsync(Uri resource)
Parameters
|
Uri
resource
Resource to request an access token for |
Returns
|
Task<string>
An access token |
Overrides
GetAccessTokenAsync(Uri, string[])
Gets an access token for the requested resource and scope
Declaration
public override Task<string> GetAccessTokenAsync(Uri resource, string[] scopes)
Parameters
|
Uri
resource
Resource to request an access token for (unused) |
|
string[]
scopes
Scopes to request |
Returns
|
Task<string>
An access token |