Setting Up Google Play Games Services

This document covers how to use the Google Play Console to set up Google Play games services for your Android game. The Google Play Console provides a centralized place for you to manage game services and configure metadata for authorizing and authenticating your game.

To add your game to the Google Play Console, follow these general steps:

  • Create a game project for your game and specify details such as the name and description of the game.
  • Create and link the necessary credentials to authorize and authenticate your game to Google Play Games Services.

These steps are covered in more detail in the sections below.

Step 1. Sign in to the Google Play Console

To sign in, go the Google Play Console. If you haven't registered for the Google Play Console before, you will be prompted to do so.

Step 2. Add your game to the Google Play Console

To add your game, follow these steps:

  1. Create a game in Play Console if you haven't already. See here for more details.
  2. Navigate to Grow > Play Games Services > Setup and management > Configuration.
  3. Specify whether your game already uses Google APIs (such as Firebase). Choosing the correct option is very important.

    • If this is a game you are creating from scratch, or you have never set up Google APIs for it previously, choose No, my game doesn't use Google APIs. Enter your game's name and then click Create.
    • If this is a game for which you have already set up one or more Google APIs, choose Yes, my game already uses Google APIs. You will see a list of projects from the Google Cloud Console for which you are listed as a developer. Select your project from the list and then click Use.
    • If you want to use an existing Play Games Services project, choose Use an existing Play Games Services project. You will see a list of existing Play Games Services projects for your account. Select the correct game project from the list and then click Use. This is not a typical choice, but you might do this if you are creating a new game in Play Console to change the package name, or if you have free and paid versions of your game with different package names.
  4. A Play Games Services game project is created, and a corresponding entry is created for you in the Google Cloud Console.

  5. In the Properties section, you can select Edit Properties and add the description, category, and graphic assets for your game.

    • Only the display name is required for testing. The other fields must be filled out before you can publish your game.
    • The display name and description for your game should match what you have set up for your game's Play Store listing.
    • For guidelines on creating the graphic assets, see the Google Play for Developers guide and the Google Play Featured-Image Guidelines.

Step 3. Generate an OAuth 2.0 client ID

Your game must have an OAuth 2.0 client ID in order to be authenticated and authorized to call the Google Play games services. To set up a credential for Play Games Services, which is the association between a client ID and your game, use Google Cloud Platform to create the client ID. Then, use Google Play Console to add a credential, linking the client ID to your game.

For more detailed instructions, see the following steps:

You may have already configured the OAuth consent screen, but if you haven't then the Credentials section will display a message notifying you that you have not done so.

Click Configure OAuth consent screen. This opens a dialog with further instructions and a deep link to the Google Cloud Platform. Note the required information described in step 2 of the instructions in the dialog.

If you have completed the setup of the OAuth consent screen, click Done. Google Play Console refreshes automatically, and if configuration was successful you will be able to create a credential:

b. Create a credential

In order to authorize your game to communicate with Google Play games services, you must create a credential with an authorized OAuth2 client ID.

In the Credentials section, click Add credential.

In the wizard, choose whether you want to create an Android credential (if your game APK will authenticate the user and use PGS APIs) or a game server credential (if your game server will use PGS APIs). Follow the instructions specific to your desired credential type.

Android

Set up credential details

Ensure that the name in the Name field matches the name of your game. Choose whether to enable Anti-Piracy.

Set up authorization

Next, choose an OAuth client ID to use for this game project. If you already have OAuth2 client IDs, you can choose one. However, you will usually create a new one. Click Create OAuth client. This opens a dialog with deep links and instructions for creating an OAuth Client ID in Google Cloud Platform.

  1. Select Android as the application type.
  2. Enter your game's name in the Name field.
  3. Enter your Android application's package name in the Package name field.
  4. Open a terminal and run the Keytool utility to get the SHA1 fingerprints of the release and debug certificates.

    To get the release certificate fingerprint, run the following command:

    keytool -list -keystore <path-to-production-keystore> -v

    To get the debug certificate fingerprint, run the following command:

    keytool -list -keystore <path-to-debug-keystore> -v

  5. The keytool utility prompts you to enter a password for the keystore. The default password for the debug keystore is android. The keytool then prints the fingerprint to the terminal.

  6. Paste the SHA1 fingerprint into the Signing certificate fingerprint (SHA1) field.

  7. Click Create.

For more information about OAuth 2.0 on Android, see Authenticating to OAuth2 Services.

After you click Done in the dialog, the available Client IDs will refresh. Choose the credential you created from the drop-down menu and then click Save Changes. This creates the credential as a draft, enabling you to authenticate to Play Games Services in your game.

You may want to create two credentials: one with the release certificate fingerprint, and one with the debug certificate fingerprint. Make sure to use the same package name for both. This allows Google Play Games Services to recognize calls from your linked APKs that are signed with either certificate. For more information about certificate signing for Android, see Sign your app.

Game server

Set up credential details

Ensure that the name in the Name field matches the name of your game.

Set up authorization

Next, choose an OAuth client ID to use for this game project. If you already have OAuth2 client IDs, you can choose one. However, you will usually create a new one. Click Create OAuth client. This opens a dialog with deep links and instructions for creating an OAuth Client ID in Google Cloud Platform.

  1. Select Web application as the application type.
  2. Enter your game's name in the Name field.
  3. Click Create.

For more information about OAuth 2.0 on Android, see Authenticating to OAuth2 Services.

After you click Done in the dialog, the available Client IDs will refresh. Choose the credential you created from the drop-down menu and then click Save Changes. This creates the credential as a draft, enabling you to authenticate to Play Games Services from your game server. For more information about using Play Games Services with your game server, see Enabling Server-Side Access to Google Play Games Services.

Avoiding common setup problems

To avoid common setup mistakes, make sure to follow these recommendations when setting up your game to use Google Play games services.

1. Set up your game with the Google Play Console
If you created an Oauth 2.0 client ID for your app in the Google Cloud Console, Google Play games services will not know about the association between the game’s achievement and leaderboards and the client ID. To create this association, you must create a credential using the Oauth 2.0 client ID as described in Create a credential.
2. Use the correct application ID in Android
The application ID is a required string resource that you must reference in your Android manifest. The application ID string consists only of the digits (typically 12 or more) at the beginning of the client ID provided by the Google Play Console. The application ID can be found at the top of the Configuration page and is labeled as Project ID below the name of your game.
3. Sign your APK with the correct certificate
When linking your Android app to your game in the Google Play Console, you must use exactly the same package name and certificate fingerprint that you used to publish your app. If there is a mismatch, calls to Google Play games services will fail. You should create two client IDs, one with the release certificate fingerprint and another with the debug certificate fingerprint, and use the same package name for both. To learn more about how to specify the signing certificate in the Google Play Console, see Signing Your Applications.
4. When developing for Android, include the Play Games SDK as a library project, not as a standalone JAR
Make sure that the Google Play services SDK is referenced as a library project in your Android project, otherwise this could lead to errors when your app is unable to find Google Play services resources. To learn how to set up your Android project to use Google Play services, see Setting Up Google Play Services.
5. Sign in with a tester account during development
If you have not published your game setting changes in the Google Play Console, you might encounter errors during testing if you are not signed in with a whitelisted tester account. You should always enable your Google Play Console publisher account for testing. To learn how to manage tester accounts, see Enabling accounts for testing.
6. At release, publish the Play Games Services settings first before you publish your game
Developers might accidentally publish their app without publishing the corresponding Google Play games services settings for their app. This might cause players who are signing in with non-tester accounts to encounter errors since the app cannot reference the correct game settings. When releasing your game, remember to first publish your game settings by using the Publish Game option in the Google Play Console. To learn how to publish your changes, see Publishing your game changes.

For additional tips, refer to these related resources:

Next steps

Before proceeding further, you should add test accounts to your game as described in Enabling accounts for testing. Users with authorized test accounts will have access to your unpublished Play Games Services game project and can test that your configured Google Play games services are working correctly.

Once you have completed the initial setup tasks described above, you can proceed to configure features for your game, such as leaderboards and achievements. To learn more, see Enable features.