UniWebViewAuthenticationFlowFacebook

Summary

A predefined authentication flow for Facebook Login.

It is not a standard OAuth2 flow, and using a plain web view. There once was a policy that Facebook did not allow any third-party customize authentication flow other than using their official SDK. Recently Facebook started to provide a so-called manual flow way to perform authentication. But it is originally only for Desktop apps, it is not stable and not standard.

Facebook suggests "For mobile apps, use the Facebook SDKs for iOS and Android, and follow the separate guides for these platforms." So on mobile, use this class with your own risk since it might be invalidated or forbidden by Facebook in the future.

This implementation is based on the manual flow described in this documentationopen in new window.

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

To allow the Facebook flow working, at least you need to set the App Id in the UniWebViewAuthenticationFlowFacebook inspector.

Properties Summary

The App ID of your Facebook application.

Optional to control this flow's behaviour.

The scope string of all your required scopes.

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 App ID of your Facebook application.

The scope string of all your required scopes.

Events

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

Example

facebookFlow.OnAuthenticationFinished.AddListener(OnFacebookTokenReceived)

void OnFacebookTokenReceived(UniWebViewAuthenticationFacebookToken token) {
  Debug.Log("Facebook Access Token: " + token.AccessToken);
}

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

Example

facebookFlow.OnAuthenticationErrored.AddListener(OnFacebookAuthError);

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