UniWebViewAuthenticationFlowTwitter

Summary

A predefined authentication flow for Twitter.

This implementation follows the flow described hereopen in new window.

See the OAuth 2.0 Support for a more detailed guide of authentication in UniWebView.

To allow the Twitter flow working, at least you need these steps:

  1. Setting Client Id, Redirect Uri in the UniWebViewAuthenticationFlowTwitter inspector.
  2. Setting Scope and at least contains users.read in the UniWebViewAuthenticationFlowTwitter inspector.
  3. Setting the Auth Callbacks Urls to contain the Redirect Uri in the UniWebView preference panel.

Properties Summary

The client ID of your Twitter application.

The redirect URI of your Twitter application.

The scope string of all your required scopes.

Optional to control this flow's behaviour.

Whether to enable PKCE when performing authentication.

Whether to enable the state verification.

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

Starts the authentication flow with the standard OAuth 2.

Starts the refresh flow with the standard OAuth 2.

Properties

The client ID of your Twitter application.

The redirect URI of your Twitter application.

The scope string of all your required scopes.

Whether to enable PKCE when performing authentication.This has to be enabled as S256, otherwise, Twitter will reject the authentication request.

Whether to enable the state verification. If enabled, the state will be generated and verified in the authentication callback. This has to be true, otherwise, Twitter will reject the authentication request.

Events

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

Example

twitterFlow.OnAuthenticationFinished.AddListener(OnTwitterTokenReceived)

void OnTwitterTokenReceived(UniWebViewAuthenticationTwitterToken token) {
  Debug.Log("Twitter Access Token: " + token.AccessToken);
}

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

Example

twitterFlow.OnAuthenticationErrored.AddListener(OnTwitterAuthError);

void OnTwitterAuthError(long error, string message) {
  Debug.Log("Error code: " + error + " Message: " + message);
}

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

Example

twitterFlow.OnRefreshTokenFinished.AddListener(OnRefreshTokenReceived)

void OnRefreshTokenReceived(UniWebViewAuthenticationTwitterToken token) {
  Debug.Log("Access Token: " + token.AccessToken);
}

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

Example

twitterFlow.OnRefreshTokenErrored.AddListener(OnRefreshTokenError);

void OnRefreshTokenError(long error, string message) {
  Debug.Log("Error code: " + error + " Message: " + message);
}

Methods

Starts the authentication flow with the standard OAuth 2.0. This implements the abstract method in UniWebViewAuthenticationCommonFlow.

Starts the refresh flow with the standard OAuth 2.0. This implements the abstract method in UniWebViewAuthenticationCommonFlow.