Class UsernamePasswordAuthenticationProvider
Authentication Provider that uses a Resource Owner Password Credentials (ROCP) credential flow
public sealed class UsernamePasswordAuthenticationProvider : OAuthAuthenticationProvider, IAuthenticationProvider
- Inheritance
-
UsernamePasswordAuthenticationProvider
- Implements
- Inherited Members
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
public UsernamePasswordAuthenticationProvider(ILogger<OAuthAuthenticationProvider> logger, IMsalHttpClientFactory msalHttpClientFactory)
Parameters
loggerILogger<OAuthAuthenticationProvider>The instance of the logger service provided by DI
msalHttpClientFactoryIMsalHttpClientFactoryThe instance of the Msal Http Client Factory service provided by DI
UsernamePasswordAuthenticationProvider(string, string, PnPCoreAuthenticationUsernamePasswordOptions)
Public constructor for external consumers of the library
public UsernamePasswordAuthenticationProvider(string clientId, string tenantId, PnPCoreAuthenticationUsernamePasswordOptions options)
Parameters
clientIdstringThe Client ID for the Authentication Provider
tenantIdstringThe Tenant ID for the Authentication Provider
optionsPnPCoreAuthenticationUsernamePasswordOptionsOptions for the authentication provider
UsernamePasswordAuthenticationProvider(string, string, string, SecureString)
Public constructor for external consumers of the library
public UsernamePasswordAuthenticationProvider(string clientId, string tenantId, string username, SecureString password)
Parameters
clientIdstringThe Client ID for the Authentication Provider
tenantIdstringThe Tenant ID for the Authentication Provider
usernamestringThe Username for authentication
passwordSecureStringThe Password for authentication
Properties
Password
The password for authenticating
public SecureString Password { get; set; }
Property Value
Username
The username for authenticating
public string Username { get; set; }
Property Value
Methods
AuthenticateRequestAsync(Uri, HttpRequestMessage)
Authenticates the specified request message.
public override Task AuthenticateRequestAsync(Uri resource, HttpRequestMessage request)
Parameters
resourceUriRequest uri
requestHttpRequestMessageThe HttpRequestMessage to authenticate.
Returns
- Task
The task to await.
GetAccessTokenAsync(Uri)
Gets an access token for the requested resource
public override Task<string> GetAccessTokenAsync(Uri resource)
Parameters
resourceUriResource to request an access token for
Returns
GetAccessTokenAsync(Uri, string[])
Gets an access token for the requested resource and scope
public override Task<string> GetAccessTokenAsync(Uri resource, string[] scopes)