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 documentation.
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. | |
The additional query arguments that are used to construct the query string of the authentication request. |
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.
Optional to control this flow's behaviour.
The scope string of all your required scopes.
The additional query arguments that are used to construct the query string of the authentication request.
This is useful when you want to add some custom parameters to the authentication request. This string will be appended to the query string that constructed from GetAuthenticationUriArguments
.
For example, if you set the value to prompt=consent&ui_locales=en
, it will be contained in the final authentication query.
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
.