Hide
Google Play Game Services

Setting Up Google Play Games Services

This document covers how to use the Google Play Developer Console to set up Game services for your Android, iOS, or web-based game.

To set up Game services, you first need to add your game to the Google Play Developer Console. In the game entry, you can specify details such as the name and description of the game.

In order for your game to access the Game services, you also need to generate the necessary credentials to authorize and authenticate your game.

You can link the game entry in the Google Play Developer Console to Android, iOS, and web versions of your game, so that players on these platforms can see the same game details and share the same Game services.

Step 1. Sign in to the Google Play Developer Console

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

Step 2. Add your game to the Google Play Developer Console

To add your game to the Google Play Developer Console:

  1. Open the Games with Game Services page and add your game.
    1. Select the Game services tab on the left.
      The Game Services tab
    2. Click the Add a New Game button.
  2. Specify if the game you are adding already uses Google APIs.
    • If this is a game you are creating from scratch, or you have never set up Google APIs for it previously, stay on the I don't use any Google APIs in my game yet tab. Enter your game's name and assign it a category, and then click the Continue button.
      The 'Create a new Game' dialog box
    • If this is a game for which you have already set up one or more Google APIs (for instance, Google+ sign-in) , select the I already use Google APIs in my game tab. You will see a list of projects from the Google Developers Console for which you are listed as a developer. Select your project from this list, assign the game a category, then click the Continue button.
      The 'Create a new Game' dialog box
  3. In the Game Details form, 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.
  4. Click Save to create a new entry for your game in the Google Play Developer Console. A corresponding entry in the Google Developers Console is also created for you.

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 Play Game services.

To set up the association between a client ID and your game, use the Google Play Developer Console to generate the client ID and link it to your game.

To generate an OAuth 2.0 client ID for your game, follow these steps:

a. Create a linked application

To link your game to a Google Developers Console project, open the Linked apps page, and then follow the instructions specific to your platform.

Android

  1. Click the Link an Android app button.
    Choosing the platform to link
  2. The application name may be shown to your players, so specify a name that closely matches the name of your actual Android game.
  3. Add the application's package name.
  4. To use Game services' real-time or turn-based multiplayer support, enable the appropriate multiplayer settings.
  5. Select whether or not to turn on Anti-Piracy.
  6. Click Save and continue, then follow the steps in the Create a client ID section below.
    Linking an Android application, step 1

iOS

  1. Click the Link an iOS app button.
    Choosing the platform to link
  2. The application name may be shown to your players, so specify a name that closely matches the name of your actual iOS game.
  3. Add the supported devices, the minimum required iOS version, and the bundle identifier from your Xcode project.
  4. You can also enter your iTunes App ID if you know it. This is not required for testing your game.
  5. Click Save and continue, then follow the steps in the Create a client ID section below.
    Linking an iOS application, step 1

Web

  1. Click the Link a web app button.
    Choosing the platform to link
  2. The application name may be shown to your players, so specify a name that closely matches the name of your actual web game.
  3. Add the URL to launch your game.
  4. Click Save and continue, then follow the steps in the Create a client ID section below.
    Linking a web application, step 1

b. Create a client ID

  1. In the Step 2: Authorize your app screen, click the Authorize your app now button to begin the process of creating an OAuth 2.0 client ID.
The 'Authorize your app' button
  1. You will be prompted to enter a project name along with an optional product logo. This information will appear in the OAuth 2.0 permissions dialog box when a user is asked to authorize your game. Your game name is placed in the project name field by default.
  2. Click Continue, then follow the steps in the Specify client ID settings section below.

c. Specify client ID settings

Next, specify your client ID settings by following the instructions specific to your platform.

Android

  1. Choose Installed application as your Application type and select Android as the installed application type (these should be your only options).
    Linking an Android application, step 2
  2. In the Package name field, enter your Android application's package name.
  3. Open a terminal and run the the Keytool utility to get the SHA1 fingerprint of the certificate. You should get both the release and debug certificate fingerprints.

    To get the release certificate fingerprint:

    keytool -exportcert \
    -alias <your-key-name> \
    -keystore <path-to-production-keystore> \
    -list -v
    
    To get the debug certificate fingerprint:
    keytool -exportcert \
    -alias androiddebugkey \
    -keystore <path-to-debug-keystore> \
    -list -v
    
  4. The keytool 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. For example:
    Certificate fingerprint: SHA1: DA:39:A3:EE:5E:6B:4B:0D:32:55:BF:EF:95:60:18:90:AF:D8:07:09
  5. Paste the SHA1 fingerprint into the Signing certificate fingerprint field.
  6. Click the Create client button, then follow the steps in the Gather credential information section below.

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

You should create two client IDs, one with the release certificate fingerprint and another with the debug certificate fingerprint. Make sure to use the same package name for both. This allows Play Game services to recognize calls from your linked APKs that are signed with either certificate. For more information about certificate signing for Android, see Signing Your Application.

You can add more than one Android app to the same game entry in Google Play Developer Console. However, this should only be done if there are different versions of the same game (for example, the free version and the paid version). In this case, always list the paid version before the free version (or the full version before the demo/trial version). Do not link different games to the same project as this may cause incorrect behavior. Instead, create a separate game entry in the Google Play Developer Console for each game that you publish.

iOS

  1. Choose Installed application as your Application type and select iOS as the installed application type (these should be the only options).
  2. Add your bundle identifier from your Xcode project and your App Store ID, if you know it. If you entered these values in the previous step, they will already be copied over into these fields by default. The bundle identifier is required. The App Store ID is optional.
  3. Click the Create client button, then follow the steps in the Gather credential information section below.
    Linking an iOS Application, step 2

Web

  1. Choose Web application as your Application type (it should be the only option).
  2. Enter the site or host name where you will be hosting your app. You can add additional sites later.
  3. An OAuth 2.0 redirect URI will automatically be created for you. You can change this later if you want to redirect to a different URI. If you're using JavaScript to handle your OAuth 2.0 sign-in, you can ignore this URI, and delete it later.
    Linking a Web application, step 2
  4. If you want more control over the hostnames and/or redirect URIs, click the more options link. This will allow you to add multiple redirect URIs, as well as multiple authorized sites (also called JavaScript Origins) from which you can call client-side OAuth. As a general rule, you should have as many authorized hosts or redirect URIs as you need for development, but no more. You should also remove URLs like "localhost" as authorized origins before you publish your game.
    • If you are using server-side OAuth (that is, redirecting to an OAuth page and redirecting back to your game), specify the page to which you redirect back in the Authorized Redirect URIs box.
    • If you are using client-side OAuth (that is, having the OAuth dialog appear in a pop-up dialog), specify the servers from which you are serving your game in the Authorized JavaScript Origins box.
      Linking a Web application, advanced options
  5. Click Create client, then follow the steps in the Gather credential information section below.

d. Gather credentials for authentication and authorization

Depending on the platform you are developing for, you may need to locate and record the following credential information.

Client ID

After you click the Create Client button, you should see your new client ID for this application. Make a note of the client ID, as you will need this information later. You will have a different client ID for each platform.

The location of the new client ID

You can always find this information later by revisiting the Linked Apps page and clicking on the linked application associated with the client ID for your platform.

Selecting previously linked applications

The client ID is listed at the bottom of the page.

The location of your client ID on the linked application page

Client secret (for web-based games only)

If you are building a web-based application, you might also need your client secret to authorize your server-based API client. You can find your client secret by clicking on the linked application entry for your web application.

At the bottom of the screen, you will see a link that redirects you to the Google Developers Console, where you will be able to find the Client Secret for this linked application.

The link to the Google Developers Console.

Application ID

You may also need to know your application ID to properly set up sign in. You can find this by looking for the 12-or-13-digit number next to your game's display name at the top of the page.

The location of the application id

e. (Optional) Creating multiple client IDs

If you are creating a game that runs on multiple platforms, you will need to create a separate client ID for each platform (Web, Android, and iOS). To do this, click the Link another app button on the Linked apps page and repeat the steps starting from the Create a linked application section.

Avoiding common setup problems

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

1. Set up your game with the Google Play Developer Console
If you created an Oauth 2.0 client ID for your app in the Google Play Developer Console, Play Game services will not know about the association between the game’s achievement and leaderboards and the client ID. To create this association, you should first link your app with the game as described in the Google Play Developer Console setup guide.
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 Developer Console. To learn how to find the application ID, see the Google Play Developer Console setup guide.
3. Sign your APK with the correct certificate
When linking your Android app to your game in the Google Play Developer 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 Play Game 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 Developer Console, see the Google Play Developer Console setup guide.
4. When developing for Android, include the Play Game services 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 the Google Play services installation guide.
5. Sign in with a tester account during development
If you have not published your game setting changes in the Google Play Developer 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 Developer Console publisher account for testing. To learn how to manage tester accounts, see the Google Play Developer Console publishing guide.
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 Play Game 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 Developer Console. To learn how to publish your changes, see the Google Play Developer Console publishing guide.

You can also 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 to your unpublished game in Google Play, and can test that your configured Game services are working correctly.

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