Table of Contents

Class ExternalAuthenticationProvider

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

Authentication Provider that relies on an external token provider

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

Constructors

ExternalAuthenticationProvider(ILogger<OAuthAuthenticationProvider>)

Public constructor leveraging DI to initialize the ILogger interfafce

public ExternalAuthenticationProvider(ILogger<OAuthAuthenticationProvider> logger)

Parameters

logger ILogger<OAuthAuthenticationProvider>

The instance of the logger service provided by DI

ExternalAuthenticationProvider(Func<Uri, string[], string>)

Public constructor for external consumers of the library

public ExternalAuthenticationProvider(Func<Uri, string[], string> accessTokenProvider)

Parameters

accessTokenProvider Func<Uri, string[], string>

A function providing the access token to use

ExternalAuthenticationProvider(Func<Uri, string[], Task<string>>)

Public constructor for external consumers of the library

public ExternalAuthenticationProvider(Func<Uri, string[], Task<string>> accessTokenProvider)

Parameters

accessTokenProvider Func<Uri, string[], Task<string>>

A function providing the access token to use

Properties

AccessTokenProvider

A function providing the access token to use

public Func<Uri, string[], string> AccessTokenProvider { get; set; }

Property Value

Func<Uri, string[], string>

AccessTokenTaskProvider

A function providing the access token to use

public Func<Uri, string[], Task<string>> AccessTokenTaskProvider { get; set; }

Property Value

Func<Uri, string[], Task<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

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

Parameters

resource Uri

Resource to request an access token for

scopes string[]

Scopes to request

Returns

Task<string>

An access token