Server-side access to Google Play Games Services
Stay organized with collections
Save and categorize content based on your preferences.
We recommend that you use GamesSignInClient
to authenticate players and securely pass the player's identity to the backend
server. This enables your game to securely retrieve the player's identity and
other data without being exposed to potential tampering while passing through
the device.
Once the player authenticates successfully, you can request a special single-use
code (called the server auth code) from the Play Games Services v2 SDK, which
the client passes to the server. Then, on the server, exchange the server auth
code for an OAuth 2.0 token that the server can use to make calls to the
Google Play Games Services API.
The following steps are required for offline access:
In the Google Play Console: Create a credential for your game server.
The OAuth client type of the credential will be "web".
In the Android app: As part of platform authentication, request a server
auth code for your server's credential, and pass that to your server. The
GamesSigninClient can request three OAuth 2.0 scopes when requesting
server-side access to Play Games Services web APIs. The optional scopes are
EMAIL, PROFILE, and OPEN_ID. The two default scopes are
DRIVE_APPFOLDER and GAMES_LITE.
On your game server: Exchange the server auth code for an OAuth access
token using Google auth services, and then use this to call the
Play Games Services
REST APIs.
Google Play Game services does not provide backend
support for Web games. However, it does provide backend server support
for your Android game's server.
Go to Play Games Services > Setup and management > Configuration.
Select Add credential to be brought to the Add credential page.
Select Game server as the credential type and continue onto the
Authorization section.
If your game server already has an OAuth client ID select it from the drop
down menu. After saving your changes, move onto
the next section.
If you don't have an existing OAuth client ID for your game server, you can
create one.
Click Create OAuth client and follow the Create OAuth Client ID
link.
This will bring you to the Google Cloud Platform's
Create OAuth Client ID page for your
project associated with your game.
Fill out the page's form and click create. Be sure to set the
Application type to Web application.
Return to the Add credential page's Authorization section, select
the newly created OAuth client and save your changes.
Get the server auth code
To retrieve a server auth code that your game can use for access tokens on your
backend server:
Call requestServerSideAccess from the client.
Be sure that you use the OAuth Client ID registered for your game
server and not the OAuth Client ID of your Android application.
(Optional) If your game server requires offline access (long lived access
using a refresh token) to Play Games Services, you can set the
forceRefreshToken parameter to true.
(Optional) As part of the authentication, new users should encounter a
single consent screen for additional scopes.
Upon accepting the consent, you set the scopes parameter with
EMAIL, PROFILE, and OPEN_ID OAuth scopes. If users decline the
consent, only the two default scopes DRIVE_APPFOLDER and GAMES_LITE are
sent to the backend.
GamesSignInClientgamesSignInClient=PlayGames.getGamesSignInClient(this);gamesSignInClient.requestServerSideAccess(OAUTH_2_WEB_CLIENT_ID,/* forceRefreshToken= / false, / Additional AuthScope */scopes).addOnCompleteListener(task->{if(task.isSuccessful()){AuthResponseauthresp=task.getResult();// Send the authorization code as a string and a// list of the granted AuthScopes that were granted by the// user. Exchange for an access token.// Verify the player with Play Games Services REST APIs.}else{// Failed to retrieve authentication code.}});
Send the OAuth auth code token to your backend server so it may be exchanged,
the Player ID verified against the Play Games Services REST APIs, and then
authenticated with your game.
Send the server auth code
Send the server auth code to your backend server to exchange for access and
refresh tokens. Use the access token to call the Play Games Services API on
behalf of the player and, optionally, store the refresh token to acquire a new
access token when the access token expires.
The following code snippet shows how you might implement the server-side code in
the Java programming language to exchange the server auth code for access
tokens.
You can retrieve the OAuth scopes using the
Google API Client Libraries
in Java or Python to get the GoogleIdTokenVerifier object. The following code
snippet shows the implementation in Java programming language.
Call
Achievements.increment
to report progress on an achievement, and find out if the player unlocked it.
If you are debugging a game that hasn't reached production, you can call
Achievements.reset
or
Achievements.resetAll
from the Management APIs to reset achievements to their original state.
To get a list of all scoreboards in the game, call
Leaderboards.list.
If a player is done with a game, you can submit their score to
Scores.submit
and find out if it is a new high score.
To display a leaderboard, get the data from
Scores.list
and show it to the user.
Use Scores.listWindow
to find an assortment of scores close to the user's high score.
To get more information about the player's score in a particular leaderboard
(for example, if the player is in the top 12% of all players), call
Scores.get.
If you are debugging a game, you can call
Scores.reset
from the Management APIs to reset all scores for that player from a particular
leaderboard.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026年06月16日 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026年06月16日 UTC."],[],[]]