Table of Contents

Class CredentialManagerAuthenticationProvider

Namespace
PnP.Core.Auth
Assembly
PnP.Core.Auth.dll

Authentication Provider that uses a set of credentials stored in the Credentials Manager of Windows

public sealed class CredentialManagerAuthenticationProvider : OAuthAuthenticationProvider, IAuthenticationProvider
Inheritance
CredentialManagerAuthenticationProvider
Implements
Inherited Members

Constructors

CredentialManagerAuthenticationProvider(ILogger<OAuthAuthenticationProvider>, IMsalHttpClientFactory)

Public constructor leveraging DI to initialize the ILogger and IMsalHttpClientFactory interfaces

public CredentialManagerAuthenticationProvider(ILogger<OAuthAuthenticationProvider> logger, IMsalHttpClientFactory msalHttpClientFactory)

Parameters

logger ILogger<OAuthAuthenticationProvider>

The instance of the logger service provided by DI

msalHttpClientFactory IMsalHttpClientFactory

The instance of the Msal Http Client Factory service provided by DI

CredentialManagerAuthenticationProvider(string, string, PnPCoreAuthenticationCredentialManagerOptions)

Public constructor for external consumers of the library

public CredentialManagerAuthenticationProvider(string clientId, string tenantId, PnPCoreAuthenticationCredentialManagerOptions options)

Parameters

clientId string

The Client ID for the Authentication Provider

tenantId string

The Tenant ID for the Authentication Provider

options PnPCoreAuthenticationCredentialManagerOptions

Options for the authentication provider

CredentialManagerAuthenticationProvider(string, string, string)

Public constructor for external consumers of the library

public CredentialManagerAuthenticationProvider(string clientId, string tenantId, string credentialManagerName)

Parameters

clientId string

The Client ID for the Authentication Provider

tenantId string

The Tenant ID for the Authentication Provider

credentialManagerName string

The Name of the Credential Manager item for authentication

Properties

CredentialManagerName

The name of the Windows Credential Manager settings to use

public string CredentialManagerName { get; set; }

Property Value

string

Methods

AuthenticateRequestAsync(Uri, HttpRequestMessage)

Authenticates the specified request message.

public override Task AuthenticateRequestAsync(Uri resource, HttpRequestMessage request)

Parameters

resource Uri

Request uri

request HttpRequestMessage

The 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

resource Uri

Resource to request an access token for

Returns

Task<string>

An access token

GetAccessTokenAsync(Uri, string[])

Gets an access token for the requested resource and scope. Provide either scopes or resource parameter.

public override Task<string> GetAccessTokenAsync(Uri resource, string[] scopes)

Parameters

resource Uri

Resource to request an access token for, only used if scopes is null

scopes string[]

Scopes to request, can be null

Returns

Task<string>

An access token