Class PkceAuthenticator
An IAuthenticator implementation that provides authentication through PKCE (Proof Key Code Exchange) standards.
Inherited Members
Namespace: Unity.DigitalTwins.Identity
Assembly: solution.dll
Syntax
public class PkceAuthenticator : IAuthenticator, IAccessTokenProvider, IDisposable
Constructors
PkceAuthenticator(IPkcePlatformSupport, IHttpClient, IAppIdProvider, IAppNameProvider, IUrlRedirectionInterceptor)
Builds a PkceAuthenticator that uses the standard Proof Key Code Exchange (PKCE) authentication flow using built-in PkceRequestHandler and PkceConfigurationProvider.
Declaration
public PkceAuthenticator(IPkcePlatformSupport pkcePlatformSupport, IHttpClient httpClient, IAppIdProvider appIdProvider, IAppNameProvider appNameProvider, IUrlRedirectionInterceptor urlRedirectionInterceptor)
Parameters
Type | Name | Description |
---|---|---|
IPkcePlatformSupport | pkcePlatformSupport | An IPkcePlatformSupport required to handle platform-specific features in the authentication flow. |
Unity.DigitalTwins.Common.IHttpClient | httpClient | An IHttpClient to reach cloud endpoints in the authentication flow. |
Unity.DigitalTwins.Common.IAppIdProvider | appIdProvider | An IAppIdProvider to inject the app identifier required on App settings cloud endpoints. |
Unity.DigitalTwins.Common.IAppNameProvider | appNameProvider | An IAppNameProvider to build the unique uri scheme used to bind the app to the browser response in a login operation. |
Unity.DigitalTwins.Common.IUrlRedirectionInterceptor | urlRedirectionInterceptor |
PkceAuthenticator(IPkcePlatformSupport, IPkceRequestHandler, IPkceConfigurationProvider, IUrlRedirectionInterceptor)
Builds a PkceAuthenticator that uses the standard Proof Key Code Exchange (PKCE) authentication flow using custom IPkceRequestHandler and IPkceConfigurationProvider.
Declaration
public PkceAuthenticator(IPkcePlatformSupport pkcePlatformSupport, IPkceRequestHandler pkceRequestHandler, IPkceConfigurationProvider pkceConfigurationProvider, IUrlRedirectionInterceptor urlRedirectionInterceptor)
Parameters
Type | Name | Description |
---|---|---|
IPkcePlatformSupport | pkcePlatformSupport | An IPkcePlatformSupport required to handle platform-specific features in the authentication flow. |
IPkceRequestHandler | pkceRequestHandler | An IPkceRequestHandler to customize http requests used in the authentication flow. |
IPkceConfigurationProvider | pkceConfigurationProvider | An alternate IPkceConfigurationProvider to override the built-in one. |
Unity.DigitalTwins.Common.IUrlRedirectionInterceptor | urlRedirectionInterceptor |
Properties
AuthenticationState
Holds the current AuthenticationState.
Declaration
public AuthenticationState AuthenticationState { get; }
Property Value
Type | Description |
---|---|
AuthenticationState |
Methods
Dispose()
Ensure disposal of any IDisposable references.
Declaration
public void Dispose()
Dispose(Boolean)
Ensure internal disposal of any IDisposable references.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | Dispose pattern boolean value received from public Dispose method. |
GetAccessTokenAsync()
Awaitable call to fetch the user access token.
Declaration
public Task<string> GetAccessTokenAsync()
Returns
Type | Description |
---|---|
Task<String> | A Task that results in the string value of the user access token when completed. |
InitializeAsync()
Initializes the PkceAuthenticator and its resulting AuthenticationState from Interface implementation and initial configuration.
Declaration
public async Task InitializeAsync()
Returns
Type | Description |
---|---|
Task | A Task. |
LoginAsync()
Performs a Login operation.
Declaration
public async Task LoginAsync()
Returns
Type | Description |
---|---|
Task | A Task. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if PkceAuthenticator was not properly initialized or if AuthenticationState is not loggedOut. |
Unity.DigitalTwins.Common.AuthenticationFailedException |
LogoutAsync()
Performs a Logout operation.
Declaration
public async Task LogoutAsync()
Returns
Type | Description |
---|---|
Task | A Task. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if PkceAuthenticator was not properly initialized or if AuthenticationState value is not LoggedIn. |
Events
AuthenticationStateChanged
Triggered when AuthenticationState of current user changes.
Declaration
public event Action<AuthenticationState> AuthenticationStateChanged
Event Type
Type | Description |
---|---|
Action<AuthenticationState> |
Remarks
Listeners of the AuthenticationStateChanged event are responsible for restricting or allowing access to any available resources and features based on the returned value.