Skip to content

Google Play Games login practical guide

Google Play Games login is a feature that lets users log in to your app with their own Play Games profile. Google Play Games is an external authentication provider that authenticates users on the app's behalf: users authenticate on the login screen that Play Games draws, and the app gets a Hive Axyl login session from that result. A session is the state in which login is complete and the Hive Axyl SDK identifies the user.

To implement it, you must combine Google external console settings, Hive Console settings, Hive Axyl SDK calls, recipe code calls, and app code. With the recipe code, the calls needed from getting credentials to activating the session come down to a single method.

This is a different login method from Google account login

Google Play Games login logs users in with their Play Games profile, and Sign in with Google logs users in with their Google account. To provide both, you must set up the integration for each one separately.

Implementation scope

The work required to implement Google Play Games login starts with preparing credentials in the Google external console and ends with displaying the screen that matches the login result.

The work in each step falls into one of the following six categories.

Category Owner Description
External console App operator Settings you configure in the Google Cloud Console and the Google Play Console.
Hive Console App operator Settings you configure in the Hive Console.
Hive Axyl SDK App developer Hive Axyl SDK methods the app calls.
Add-on App developer The Hive Axyl SDK extension package that displays the Play Games login screen and receives an authorization code.
Recipe code App developer Recipe methods the app calls.
App code App developer Parts the app implements directly without going through Hive Axyl.

Google Play Games login has no Hive Axyl Server API calls. The app does not call the Add-on directly; the recipe calls it on the app's behalf, so the Add-on appears in the list of tasks the recipe performs internally rather than as a step category. For the meaning of the parameters and the response fields, see the detailed procedure linked in each step.

Recipe

The Hive Axyl SDK provides login features as fine-grained methods. Getting an authorization code from Play Games is split into three Add-on calls, and the method that turns that authorization code into credentials, the method that logs in with the credentials, the method that issues tokens, and the method that activates the session are all separate. Even to log in a single user, the app must put together the call order and the handling of failures along the way by itself.

A recipe is source code that completes that combination in advance. Instead of installing it as a package, you copy it into your project.

Category Location Characteristics
Hive Axyl SDK Unity package com.com2usplatform.hiveaxyl.* You install and use it. It provides authentication features as fine-grained methods.
Recipe Assets/Recipes/ProviderLogin/, Assets/Recipes/ProviderLogin.Gpg/ You copy and use it. Plain C# code that groups SDK calls by purpose.
Usage example Assets/RecipeExamples/Authentication/ProviderLoginExample.cs Code you read for reference. Its comments explain the login flow common to all external authentication providers and the parts the app must implement for each result.
Recipes are code you copy and use

Recipes are copied into your app and become your app's code. You can use them as is or modify them to fit your app's policies.

The login recipe is not tied to a single external authentication provider. ProviderLogin.Gpg/ handles only the part that gets Play Games credentials, and the rest of the process uses the same code as Apple or Steam login.

OSs supported by the recipe

Use the recipe's Play Games credential source only on Android, where the Play Games login Add-on works. A credential source is an object that displays the Play Games login screen and receives the user identifier and the authentication result. If you call this source on any other OS, it returns an Unavailable error because the Add-on is not registered. This does not mean that the login was rejected; it means that Play Games login cannot run in that environment.

OS Authentication method Implementation method
Android Native login screen that Play Games draws Follow the procedure in this guide.
iOS, Windows, macOS None Play Games login works only on Android. Use another login method that works on that OS, such as Sign in with Google.

Even on Android, this applies only to apps distributed through Google Play. This is because Play Games verifies the app by the package name and signature of the app registered in Google Play.

What the app implements

The recipe handles only the steps from getting credentials to activating the session on the app's behalf. The app implements the following items outside the recipe.

  • The login screen and the screen transition after login
  • The branch that hides the Play Games login button on OSs other than Android
  • Creating and storing DeviceKey
  • Storing the session token received from login
  • The retry policy and user-facing messages when a failure occurs

Common prerequisites

Before you start implementing, prepare the following items.

Item to prepare Required Category Where to check
Register the app in the Google Play Console and check the package name Required External console Register the store App ID
Create a project Required Hive Console Create a project
Create an Android App ID Required Hive Console Create an App ID
Register the Store App ID Required Hive Console Register the store App ID
Check the Client ID Required Hive Console Get the security key
Connect the SDK to your Unity project Required Hive Axyl SDK Connect the SDK to your Unity project

Play Games login works only with App IDs whose runtime environment is Android, so select Android as the runtime environment when you create the App ID. For Store App ID, enter the package name you checked in the Google Play Console. You enter the App ID when you initialize the SDK and the Client ID when you log in, so you must check both first. Connect the SDK first so that you can install the authentication module and the Add-on in the following steps.

Next steps

Once you have completed the prerequisites, start Implement Google Play Games login.