Google Play Games
Last updated
Was this helpful?
Was this helpful?
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using LootLocker.Requests;
using System.Collections.Generic;
public class GoogleSignIn : MonoBehaviour
{
// Example of activating Google Play Games and starting a session with LootLocker
public void Start()
{
PlayGamesPlatform.Activate();
PlayGamesPlatform.Instance.Authenticate((response) =>
{
if (response == GooglePlayGames.BasicApi.SignInStatus.Success)
{
// Add desired scopes for server-side access
List<AuthScope> scopes = new List<AuthScope>
{
AuthScope.OPEN_ID
};
PlayGamesPlatform.Instance.RequestServerSideAccess(true, scopes, (google) =>
{
if (google != null)
{
string token = google.GetAuthCode();
LootLockerSDKManager.StartGooglePlayGamesSession(token, (response) =>
{
if (response.success)
{
Debug.Log("Successfully started LootLocker session with Google Play Games.");
}
else
{
Debug.Log("LootLocker Google Play Games session failed: " + response.Error);
}
});
}
else
{
Debug.Log("Google server-side access request failed.");
}
});
}
else
{
Debug.Log("Google Play Games authentication failed: " + response);
}
});
}
}curl --location --request POST 'https://api.lootlocker.com/game/session/google-play-games/v1/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"game_api_key": "string",
"auth_code": "string",
"game_version": "string",
"optionals": {
"timezone": "string",
"player_name": "string"
}
}'{
"session_token": "string",
"player_identifier": "string",
"player_id": 0,
"player_name": "string",
"player_ulid": "string",
"player_created_at": "string",
"public_uid": "string",
"seen_before": true,
"check_grant_notifications": true,
"check_deactivation_notifications": true,
"check_dlcs": [
"string"
],
"success": true
}