docs.unity3d.com
    Show / Hide Table of Contents

    Class PkceAuthenticator

    Provides authentication through PKCE (Proof Key Code Exchange) standards.

    Inheritance
    Object
    PkceAuthenticator
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Cloud.Identity
    Syntax
    public class PkceAuthenticator : IUrlRedirectionAuthenticator, IAuthenticator, IAccessTokenProvider, IAuthenticatedUserInfoProvider, IAuthenticationStateProvider, IDisposable

    Constructors

    PkceAuthenticator(IAuthenticationPlatformSupport, IHttpClient, IAppIdProvider, IAppNameProvider, IServiceHostResolver)

    Builds a PkceAuthenticator that uses the standard Proof Key Code Exchange (PKCE) authentication flow using built-in PkceRequestHandler and PkceConfigurationProvider.

    Declaration
    [Obsolete("Use the constructor with PkceAuthenticatorSettings injection instead.")]
    public PkceAuthenticator(IAuthenticationPlatformSupport authenticationPlatformSupport, IHttpClient httpClient, IAppIdProvider appIdProvider, IAppNameProvider appNameProvider, IServiceHostResolver serviceHostResolver = null)
    Parameters
    Type Name Description
    IAuthenticationPlatformSupport authenticationPlatformSupport

    An IAuthenticationPlatformSupport required to handle platform-specific features in the authentication flow.

    IHttpClient httpClient

    An IHttpClient to reach cloud endpoints in the authentication flow.

    IAppIdProvider appIdProvider

    An IAppIdProvider to inject the app identifier required on App settings cloud endpoints.

    IAppNameProvider appNameProvider

    An IAppNameProvider to build the unique uri scheme used to bind the app to the browser response in a login operation.

    IServiceHostResolver serviceHostResolver

    The service host resolver for the service Url.

    PkceAuthenticator(IAuthenticationPlatformSupport, IHttpClient, IPkceRequestHandler, IPkceConfigurationProvider)

    Builds a PkceAuthenticator that uses the standard Proof Key Code Exchange (PKCE) authentication flow using custom IPkceRequestHandler and IPkceConfigurationProvider.

    Declaration
    [Obsolete("Use the constructor with PkceAuthenticatorSettings injection instead.")]
    public PkceAuthenticator(IAuthenticationPlatformSupport authenticationPlatformSupport, IHttpClient httpClient, IPkceRequestHandler pkceRequestHandler, IPkceConfigurationProvider pkceConfigurationProvider)
    Parameters
    Type Name Description
    IAuthenticationPlatformSupport authenticationPlatformSupport

    An IAuthenticationPlatformSupport required to handle platform-specific features in the authentication flow.

    IHttpClient httpClient

    An IHttpClient to reach cloud endpoints 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.

    PkceAuthenticator(IAuthenticationPlatformSupport, IPkceConfigurationProvider, IServiceHostResolver, IAccessTokenExchanger<String, UnityServicesToken>, IPkceRequestHandler)

    Builds a PkceAuthenticator that uses the standard Proof Key Code Exchange (PKCE) authentication flow.

    Declaration
    [Obsolete("Use the constructor with PkceAuthenticatorSettings injection instead.")]
    public PkceAuthenticator(IAuthenticationPlatformSupport authenticationPlatformSupport, IPkceConfigurationProvider pkceConfigurationProvider, IServiceHostResolver serviceHostResolver, IAccessTokenExchanger<string, UnityServicesToken> accessTokenExchanger, IPkceRequestHandler pkceRequestHandler)
    Parameters
    Type Name Description
    IAuthenticationPlatformSupport authenticationPlatformSupport

    An IAuthenticationPlatformSupport required to handle platform-specific features in the authentication flow.

    IPkceConfigurationProvider pkceConfigurationProvider

    An alternate IPkceConfigurationProvider to override the built-in one.

    IServiceHostResolver serviceHostResolver

    The service host resolver for the service Url.

    IAccessTokenExchanger<String, UnityServicesToken> accessTokenExchanger

    A Unity Services token exchange class.

    IPkceRequestHandler pkceRequestHandler

    An IPkceRequestHandler to customize http requests used in the authentication flow.

    PkceAuthenticator(PkceAuthenticatorSettings)

    Provides a PkceAuthenticator that accepts a PkceAuthenticatorSettings to handle Proof Key Code Exchange (PKCE) authentication contexts.

    Declaration
    public PkceAuthenticator(PkceAuthenticatorSettings pkceAuthenticatorSettings)
    Parameters
    Type Name Description
    PkceAuthenticatorSettings pkceAuthenticatorSettings

    A PkceAuthenticatorSettings that contains the parameters required for constructing the authenticator.

    Properties

    AuthenticationState

    Holds the current AuthenticationState.

    Declaration
    public AuthenticationState AuthenticationState { get; }
    Property Value
    Type Description
    AuthenticationState
    Implements
    IAuthenticationStateProvider.AuthenticationState

    Methods

    CancelLogin()

    Cancels the awaiting login operation.

    Declaration
    public void CancelLogin()
    Implements
    IUrlRedirectionAuthenticator.CancelLogin()
    Exceptions
    Type Condition
    InvalidOperationException

    Dispose()

    Disposes of any IDisposable references.

    Declaration
    public void Dispose()
    Implements
    IDisposable.Dispose()

    Dispose(Boolean)

    Disposes 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()

    Declaration
    public async Task<string> GetAccessTokenAsync()
    Returns
    Type Description
    Task<String>
    Implements
    IAccessTokenProvider.GetAccessTokenAsync()

    GetUserInfo(String)

    Declaration
    public string GetUserInfo(string key)
    Parameters
    Type Name Description
    String key
    Returns
    Type Description
    String
    Implements
    IAuthenticatedUserInfoProvider.GetUserInfo(String)

    HasValidPreconditionsAsync()

    Indicates if the IAuthenticator has valid preconditions to provide authentication in the current execution context.

    Declaration
    public Task<bool> HasValidPreconditionsAsync()
    Returns
    Type Description
    Task<Boolean>

    A task that when completed indicates if the IAuthenticator has valid preconditions to provide authentication in the current execution context.

    Implements
    IAuthenticator.HasValidPreconditionsAsync()

    InitializeAsync()

    A task to initialize the AuthenticationState from either cache or direct injection value.

    Declaration
    public async Task InitializeAsync()
    Returns
    Type Description
    Task
    Implements
    IAuthenticator.InitializeAsync()

    LoginAsync()

    Performs a login operation.

    Declaration
    public async Task LoginAsync()
    Returns
    Type Description
    Task

    A task.

    Implements
    IUrlRedirectionAuthenticator.LoginAsync()
    Exceptions
    Type Condition
    InvalidOperationException
    AuthenticationFailedException

    LogoutAsync(Boolean)

    Performs a logout operation.

    Declaration
    public async Task LogoutAsync(bool clearBrowserCache = false)
    Parameters
    Type Name Description
    Boolean clearBrowserCache

    An optional boolean value that, if set to true, triggers a navigation to the OS default browser to clear any cached session.

    Returns
    Type Description
    Task

    A task.

    Implements
    IUrlRedirectionAuthenticator.LogoutAsync(Boolean)
    Remarks

    A logout operation clears the user session in the application only. Unless the user manually clears the session in the browser that is used for authentication, a user can get automatically logged in again from cached values, without entering any credentials. Use the clearBrowserCache boolean to also clear the session in the browser to prevent automatic login from a cached session.

    Exceptions
    Type Condition
    InvalidOperationException

    Events

    AuthenticationStateChanged

    Triggers when the AuthenticationState of the current user changes.

    Declaration
    public event Action<AuthenticationState> AuthenticationStateChanged
    Event Type
    Type Description
    Action<AuthenticationState>
    Implements
    IAuthenticationStateProvider.AuthenticationStateChanged
    Remarks

    Subscribers of this event should restrict or allow access to available resources and features based on the returned value.

    DeviceTokenRefreshed

    Raised when the authenticator's DeviceToken is refreshed.

    Declaration
    [Obsolete("Not required when using the constructor with IAccessTokenExchanger injection.")]
    public event Action<DeviceToken> DeviceTokenRefreshed
    Event Type
    Type Description
    Action<DeviceToken>
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023