Skip to main content
Version: 5.17.0

GoogleLogin

public void GoogleLogin(GoogleLoginCallback googleLoginCallback);\ public void GoogleLogin(string webClientId, 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

Description

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

Example

public void StartGoogleLogin() {
TheBackend.ToolKit.GoogleLogin.Android.GoogleLogin(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 the incorrect android ClientID 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)

Parameters

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");
}
}