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.

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 dictionary contains the parameters that are used to perform the access token exchange 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.

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 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 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.