Table of Contents

Class X509CertificateAuthenticationProvider

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

Authentication Provider based on the X.509 Certificate

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

Constructors

X509CertificateAuthenticationProvider(ILogger<OAuthAuthenticationProvider>, IMsalHttpClientFactory)

Public constructor leveraging DI to initialize the ILogger and IMsalHttpClientFactory interfaces

public X509CertificateAuthenticationProvider(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

X509CertificateAuthenticationProvider(string, string, PnPCoreAuthenticationX509CertificateOptions)

Public constructor for external consumers of the library

public X509CertificateAuthenticationProvider(string clientId, string tenantId, PnPCoreAuthenticationX509CertificateOptions options)

Parameters

clientId string

The Client ID for the Authentication Provider

tenantId string

The Tenant ID for the Authentication Provider

options PnPCoreAuthenticationX509CertificateOptions

Options for the authentication provider

X509CertificateAuthenticationProvider(string, string, StoreName, StoreLocation, string)

Public constructor for external consumers of the library

public X509CertificateAuthenticationProvider(string clientId, string tenantId, StoreName storeName, StoreLocation storeLocation, string thumbprint)

Parameters

clientId string

The Client ID for the Authentication Provider

tenantId string

The Tenant ID for the Authentication Provider

storeName StoreName

The Store Name to get the X.509 certificate from

storeLocation StoreLocation

The Store Location to get the X.509 certificate from

thumbprint string

The Thumbprint of the X.509 certificate

X509CertificateAuthenticationProvider(string, string, X509Certificate2)

Public constructor for external consumers of the library

public X509CertificateAuthenticationProvider(string clientId, string tenantId, X509Certificate2 certificate)

Parameters

clientId string

The Client ID for the Authentication Provider

tenantId string

The Tenant ID for the Authentication Provider

certificate X509Certificate2

The X.509 certificate to use for authentication

Properties

Certificate

The X.509 Certificate to use for app authentication

public X509Certificate2 Certificate { get; set; }

Property Value

X509Certificate2

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

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

Parameters

resource Uri

Resource to request an access token for (unused)

scopes string[]

Scopes to request

Returns

Task<string>

An access token