IUniWebViewAuthenticationFlow

Summary

IUniWebViewAuthenticationFlow<TTokenType> is an interface for implementing a custom authentication flow. An authentication flow, in UniWebView, usually a "code" based OAuth 2.0 flow, contains a standard set of steps:

  1. User is navigated to a web page that requires authentication;
  2. A temporary code is generated by service provider and provided to client by a redirect URL with customized scheme.
  3. Client requests an access token using the temporary code by performing an "access token" exchange request.

To use the common flow, any customize authentication flow must implement this interface and becomes a subclass of UniWebViewAuthenticationCommonFlow.

Events Summary

Called when the authentication flow succeeds and a valid token is generated.

Called when any error (including user cancellation) happens during the authentication flow.

Called when the access token refresh request finishes and a valid refreshed token is generated.

Called when any error (including user cancellation) happens during the authentication flow.

Methods Summary

Returns the redirect URL that is used to redirect the user after authenticated.

Returns the config of the authentication flow.

Returns a dictionary contains the parameters that are used to perform the authentication request.

Returns a string contains the additional query arguments that are used to construct the query string of the authentication request.

Returns a dictionary contains the parameters that are used to perform the access token exchange request.

Returns a dictionary contains the parameters that are used to perform the access token refresh request.

Returns the strong-typed token for the authentication process.

Events

Called when the authentication flow succeeds and a valid token is generated.

Called when any error (including user cancellation) happens during the authentication flow.

Called when the access token refresh request finishes and a valid refreshed token is generated.

Called when any error (including user cancellation) happens during the authentication flow.

Methods

Returns the redirect URL that is used to redirect the user after authenticated. This is used as the redirect_uri parameter when navigating user to the authentication page.

Usually this is a URL with customize scheme that later service provider may call. It takes intermediate code in its query and can be used to open the current app in client. The native side of UniWebView will catch and handle it, then send it to Unity side as the result of UniWebViewAuthenticationSession.

Return Value

The redirect URL set in the OAuth settings.

Returns the config of the authentication flow. It usually defines the authentication requests entry points.

Return Value

The config object of an authentication flow.

Returns a dictionary contains the parameters that are used to perform the authentication request. The key value pairs in the dictionary are used to construct the query string of the authentication request.

This usually contains fields like client_id, redirect_uri, response_type, etc.

Return Value

The dictionary indicates parameters that are used to perform the authentication request.

Returns a string contains the additional query arguments that are used to construct the query string of the authentication request.

If you want to add some extra query arguments to the authentication request, you can override this method and return a string that contains the additional query arguments. The returned string will be appended to the query string that constructed from GetAuthenticationUriArguments.

Return Value

The additional query arguments that are used to construct the query string of the authentication request.

Returns a dictionary contains the parameters that are used to perform the access token exchange request. The key value pairs in the dictionary are used to construct the HTTP form body of the access token exchange request.

Parameters
  • string authResponse

    The response from authentication request. If the authentication succeeds, it is usually a custom scheme URL with a code query as its parameter. Base on this, you could construct the body of the access token exchange request.

Return Value

The dictionary indicates parameters that are used to perform the access token exchange request.

Returns a dictionary contains the parameters that are used to perform the access token refresh request. /// The key value pairs in the dictionary are used to construct the HTTP form body of the access token refresh request.

Parameters
  • string refreshToken

    The refresh token you received from a previous access token exchange request. If the access token can be refreshed, the service provider should provide you a refresh token under the refresh_token field of the response body along side with the access token exchange when you issue the access token.

Return Value

he dictionary indicates parameters that are used to perform the access token refresh request.

Returns the strong-typed token for the authentication process. When the token exchange request finishes without problem, the response body will be passed to this method and any conforming class should construct the token object from the response body.

Parameters
  • string exchangeResponse

    The body response of the access token exchange request. Usually it contains the desired access_token and other necessary fields to describe the authenticated result.

Return Value

A token object with TToken type that represents the authenticated result.