Skip to content

Sign in with Google

This how-to walks you through configuring Sign in with Google and starting a Google session from your game.

Prerequisites

  • Unity, Unreal, or Godot SDK installed and configured in your project (not required for REST).
  • A Google account with access to the Google Cloud Console to create an OAuth2 Client ID.

Configuration

Configure your integration in the platform settings.

Google Sign In platform settings in the Web Console

Client ID: retrieve this from the Google Dev Console. Create an OAuth2 Client ID if you don't already have one.

Start Session

Acquire a Google Identity Token, then use it to start a session. The response includes a refresh token, which lets you refresh the session without repeating the full sign-in flow.

string idToken = "eyJhbGciOiJSUz............";
LootLockerSDKManager.StartGoogleSession(idToken, (response) =>
{
if (!response.success)
{
Debug.Log("error starting LootLocker session");
return;
}
Debug.Log("session started successfully");
// Store these to be able to refresh the session without using the full sign in flow
string refreshToken = response.refresh_token;
});

Refresh Session

Refresh the session instead of having the player go through the full sign-in flow every time. The request returns a 401 (Unauthorized) if the refresh token has expired, in which case start a new session instead.

LootLockerSDKManager.RefreshGoogleSession((response) =>
{
if (!response.success)
{
if (response.statusCode == 401) {
// Refresh token has expired, use StartGoogleSession
}
else {
Debug.Log("error starting LootLocker session");
}
return;
}
Debug.Log("session started successfully");
});

Conclusion

You've started using LootLocker in your game with Sign in with Google. Next, review LootLocker's full feature set to decide which other features to implement.