Class OnBehalfOfAuthenticationProvider
Authentication Provider based on the OnBehalfOf flow
public sealed class OnBehalfOfAuthenticationProvider : OAuthAuthenticationProvider, IAuthenticationProvider
- Inheritance
-
OnBehalfOfAuthenticationProvider
- Implements
- Inherited Members
Remarks
You can find further details about the On-Behalf-Of flow here: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow
Constructors
OnBehalfOfAuthenticationProvider(ILogger<OAuthAuthenticationProvider>, IMsalHttpClientFactory)
Public constructor leveraging DI to initialize the ILogger and IMsalHttpClientFactory interfaces
public OnBehalfOfAuthenticationProvider(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
OnBehalfOfAuthenticationProvider(string, string, PnPCoreAuthenticationOnBehalfOfOptions, Func<string>, bool)
Public constructor for external consumers of the library
public OnBehalfOfAuthenticationProvider(string clientId, string tenantId, PnPCoreAuthenticationOnBehalfOfOptions options, Func<string> userTokenProvider, bool useSharedCache = false)
Parameters
clientIdstringThe Client ID for the Authentication Provider
tenantIdstringThe Tenant ID for the Authentication Provider
optionsPnPCoreAuthenticationOnBehalfOfOptionsOptions for the authentication provider
userTokenProviderFunc<string>A function providing the consumer user access token to use for the On-Behalf-Of flow
useSharedCacheboolShare the cache between all ClientApplication objects. The cache becomes static. Defaults to false
OnBehalfOfAuthenticationProvider(string, string, StoreName, StoreLocation, string, Func<string>, bool)
Public constructor for external consumers of the library
public OnBehalfOfAuthenticationProvider(string clientId, string tenantId, StoreName storeName, StoreLocation storeLocation, string thumbprint, Func<string> userTokenProvider, bool useSharedCache = false)
Parameters
clientIdstringThe Client ID for the Authentication Provider
tenantIdstringThe Tenant ID for the Authentication Provider
storeNameStoreNameThe Store Name to get the X.509 certificate from
storeLocationStoreLocationThe Store Location to get the X.509 certificate from
thumbprintstringThe Thumbprint of the X.509 certificate
userTokenProviderFunc<string>A function providing the consumer user access token to use for the On-Behalf-Of flow
useSharedCacheboolShare the cache between all ClientApplication objects. The cache becomes static. Defaults to false
OnBehalfOfAuthenticationProvider(string, string, X509Certificate2, Func<string>, bool)
Public constructor for external consumers of the library
public OnBehalfOfAuthenticationProvider(string clientId, string tenantId, X509Certificate2 certificate, Func<string> userTokenProvider, bool useSharedCache = false)
Parameters
clientIdstringThe Client ID for the Authentication Provider
tenantIdstringThe Tenant ID for the Authentication Provider
certificateX509Certificate2The X.509 certificate to use for authentication
userTokenProviderFunc<string>A function providing the consumer user access token to use for the On-Behalf-Of flow
useSharedCacheboolShare the cache between all ClientApplication objects. The cache becomes static. Defaults to false
OnBehalfOfAuthenticationProvider(string, string, SecureString, Func<string>, bool)
Public constructor for external consumers of the library
public OnBehalfOfAuthenticationProvider(string clientId, string tenantId, SecureString clientSecret, Func<string> userTokenProvider, bool useSharedCache = false)
Parameters
clientIdstringThe Client ID for the Authentication Provider
tenantIdstringThe Tenant ID for the Authentication Provider
clientSecretSecureStringThe Client Secret of the app
userTokenProviderFunc<string>A function providing the consumer user access token to use for the On-Behalf-Of flow
useSharedCacheboolShare the cache between all ClientApplication objects. The cache becomes static. Defaults to false
Properties
Certificate
The X.509 Certificate to use for app authentication
public X509Certificate2 Certificate { get; set; }
Property Value
ClientSecret
The ClientSecret to authenticate the app with ClientId
public SecureString ClientSecret { get; set; }
Property Value
UseSharedCache
Share the cache between all ClientApplication objects. The cache becomes static. Defaults to false.
public bool UseSharedCache { get; set; }
Property Value
UserTokenProvider
A function providing the consumer user access token to use for the On-Behalf-Of flow
public Func<string> UserTokenProvider { 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)