Skip to main content
Version: 5.11.8

GoogleLogin

public void GoogleLogin(bool isCallbackInMainThread, GoogleLoginCallback googleLoginCallback);
public void GoogleLogin(string webClientId, bool isCallbackInMainThread, GoogleLoginCallback googleLoginCallback);

public void GoogleLoginCallback(bool isSuccess, string errorMessage, string token)

Parameters

ValueTypeDescription
webClientIdstring(When the inspector is not configured) Web client ID set in Google Cloud Platform
googleLoginCallbackGoogleLoginCallbackCallback method that loads the login request success status, error message, and token value
Main thread and external thread

If an object or function created using UnityEngine or UnityEngine.UI is called from Unity or an external thread, an exception occurs.

When a callback is called to the main thread, a crash may occur if numerous objects are created in the callback, synchronous form BACKND functions cause the game to stop temporarily, or if a heavy action takes place.

Description

Attempts Google login. The result can be checked through the GoogleLoginCallback callback event.
After a successful Google login, you will be automatically logged into the previously selected ID whenever Google login is called.
To reselect the account, call TheBackend.ToolKit.GoogleLogin.Android.GoogleSignOut below.

Example

public void StartGoogleLogin() {
TheBackend.ToolKit.GoogleLogin.Android.GoogleLogin(true, GoogleLoginCallback);
}

private void GoogleLoginCallback(bool isSuccess, string errorMessage, string token) {
if (isSuccess == false) {
Debug.LogError(errorMessage);
return;
}

Debug.Log("Google token : " + token);
var bro = Backend.BMember.AuthorizeFederation(token, FederationType.Google);
Debug.Log("Federation login result : " + bro);
}

ReturnCase

Success cases

When Google login is called successfully
true
errorMessage : "" token :

eyJhbGciOiJSUzI1NiIsImtpZCI6Ijg1ZTU1MTA3NDY2YjdlMjk4MzYxOTljNThjNzU4MWY1YjkyM2JlNDQiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiI0NTk2MDkyMzQ5MDAtMGZrdHBlbjlsNzYxZjFnc3RvdTI0a2Z0dXNlcGpvZGIuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiI0NTk2MDkyMzQ5MDAtbnZzaW51bDllMnBvMGU4cGk2aWdqNmlvNGNnN3VmMG4uYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMTcxMTQ5NTAzOTIxNjIzMzA5MjAiLCJlbWFpbCI6InJsYWd1c3RtZDAyMTdAZ21haWwuY29tIiwiZW1haWxfdmVyDSDjksdajfaskljfkjksuYDtmITsirkiLCJwaWN0dXJlIjoiaHR0cHM6Ly9saDMuZ29vZ2xldXNlcmNvbnRlbnQuY29tL2EvQUNnOG9jSXprNWExOVpaQ3MyRmJ3ZG5FV0xGdDZIZUFMRUY4OUF6TF9rbFlaRXQxPXM5Ni1jIiwiZ2l2ZW5fbmFtZSI6Iu2YhOyKuSIsImZhbWlseV9uYW1lIjoi6rmAIiwibG9jYWxlIjoia28iLCJpYXQiOjE3MDY0NDA2MjMsImV4cCI6MTcwNjQ0NDIyM30.hJx5COWQWmMejDFz76b2NxAB3IcYP3obvQ6CGvwCF6oBQG7rqZzlA9YiQhQwpzd0SM6rt-aFPlrpO6yCF8V_sh2yfI784wf1VNzlhtxoajI_LpDmdny1bWlgpHGv3hwC3lL1Wi9tP2CkEfnlfTXnKXKtsPD1KiaQa8tYZnIXDR_MvnE9FtiNA-vGCclUcUdONgcgF8_tAieKVKJxfIGx2zNNCb19910abbMwkW8-lhWp6kgd

Error cases

When the running device is not Android
false
errorMessage : "SDK Exception : not support os: [ platform ]"
token : ""(string.Empty)

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.)
token : ""(string.Empty)

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

When an invalid android client ID is registered to GCP
bool : false
errorMessage : "GoogleLogin Failed. Reason : 10: "(10: is an error message returned from Google SDK.)
token : ""(string.Empty)


GoogleSignOut

public void GoogleLogin(GoogleSignOutCallback googleSignOutCallback);

public void GoogleSignOutCallback(bool isSuccess, string errorMessage)

Parameter

ValueTypeDescription
googleSignOutCallbackGoogleSignOutCallbackCallback method that loads the login request success status, error message, and token value

Description

Logs out from the Google ID. The account can be reselected upon a subsequent Google login.

Example

public void SignOutGoogleLogin() {
TheBackend.ToolKit.GoogleLogin.Android.GoogleSignOut(GoogleSignOutCallback);
}

private void GoogleSignOutCallback(bool isSuccess, string error) {
if (isSuccess == false) {
Debug.Log("Google logout error response occurred : " + error);
} else {
Debug.Log("Logout successful");
}
}