Skip to main content
Version: SDK-5.11.4

GoogleLogin

info

Google login code needs to have both GoogleLogin and OnGoogleLogin codes implemented. OnGoogleLogin needs to be set first before calling GoogleLogin.

public bool GoogleLogin(string webClientId, out string errorMessage);

Parameters

ValueTypeDescription
webClientIdstringWeb ClientID set in Google Cloud Platform
errorMessageStringAn empty value for success / error information for failure

Attempts Google login. The result can be checked through the OnGoogleLogin callback event.

Example

public void StartGoogleLogin()
{
#if UNITY_ANDROID
string message;
var result = BackendFederation.Android.GoogleLogin("123456789-abcdefghigkelnop12351.apps.googleusercontent.com", out message);
if (result == false)
{
Debug.LogError(message);
}
#endif
}

Return cases

Success cases

When Google login is called successfully
This status does not mean Google login was successful. You can check whether the login was successful with the result value of onGetAccessToken.
true
errorInfo : ErrorInfo.Success

Error cases

When the running device is not Android
false
errorMessage : "not support os: [ platform ]"


OnGoogleLogin

public void OnGoogleLogin(bool isSuccess, string errorMessage, string token);

ValueTypeDescription
isSuccessboolGoogle login success status
errorMessageStringAn empty value for success / error information for failure
tokenStringA token that will be used for Google login for success / empty value for failure

Description

Register a callback that is returned after calling the GoogleLogin method.
You can check if Google login was successful for that particular callback. A token is returned if the login was successful.

You can use the token to proceed with federated login.

Example

void Start()
{
#if UNITY_ANDROID
//Register a callback that tells the result after calling Google login
BackendFederation.Android.OnGoogleLogin += (bool isSuccess, string errorMessage, string token) =>
{
if (isSuccess == false)
{
Debug.LogError(errorMessage);
return;
}
var loginBro = Backend.BMember.AuthorizeFederation(token, FederationType.Google);
Debug.Log("Login result : " + loginBro);
};
#endif
}

Error cases

When the information set in Google Cloud Platform is invalid
bool : false
errorMessage : "GoogleLogin Failed. Reason : 10: "(10: is an error message returned from Google SDK.)

When the login attempt was not from a tester (except the production stage)
bool : false
errorMessage : "GoogleLogin Failed. Reason : 10: "(10: is an error message returned from Google SDK.)

When incorrect webClientID was used
bool : false
errorMessage : "GoogleLogin Failed. Reason : 10: "(10: is an error message returned from Google SDK.)