UniWebViewAuthenticationFlowGitHub

Summary

A predefined authentication flow for GitHub.

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 GitHub flow working, at least you need these steps:

  1. Setting Client Id, Client Secret, Callback Url in the UniWebViewAuthenticationFlowGitHub inspector.
  2. Setting the Auth Callbacks Urls containing the Callback Url in the UniWebView preference panel.

Properties Summary

The client ID of your GitHub application.

The client secret of your GitHub application.

The callback URL of your GitHub application.

Optional to control this flow's behaviour.

The redirect URI should be used in exchange token request.

Suggests a specific account to use for signing in and authorizing the app.

The scope string of all your required scopes.

Whether to enable the state verification.

Whether or not unauthenticated users will be offered an option to sign up for GitHub during the OAuth flow.

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

Starts the authentication flow with the standard OAuth 2.

Properties

The client ID of your GitHub application.

Example

At the day of writing, the client Id from GitHub is something like:

githubFlow.clientId = "lv1.1234567890abcdef1234";

The client secret of your GitHub application.

The callback URL of your GitHub application.

Example

githubFlow.callbackUrl = "authhub://auth";

The redirect URI should be used in exchange token request.

Suggests a specific account to use for signing in and authorizing the app.

The scope string of all your required scopes.

Whether to enable the state verification. If enabled, the state will be generated and verified in the authentication callback.

Default is false.

Whether or not unauthenticated users will be offered an option to sign up for GitHub during the OAuth flow.

Default is true.

Events

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

Example

githubFlow.OnAuthenticationFinished.AddListener(OnGitHubTokenReceived)

void OnGitHubTokenReceived(UniWebViewAuthenticationGitHubToken token) {
  Debug.Log("Github Access Token: " + token.AccessToken);
}

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

Example

github.OnAuthenticationErrored.AddListener(OnGitHubAuthError);

void OnGitHubAuthError(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.