16 December 2016
Posted by Clayton Wilkinson, Developer Platform Engineer
Some changes are coming to Play Game Services in early 2017:
In November, we announced an update to Google Sign-In API. Play Game Services is being updated to use Google Sign-In API for authentication. The advantages are:
This change unifies the Google Sign-in and the Games API Sign-in, so there are updates to how to build the Google API Client:
// Defaults to Games Lite scope, no server component GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN).build(); // OR for apps with a server component GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN) .requestServerAuthCode(SERVER_CLIENT_ID) .build(); // OR for developers who need real user Identity GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN) .requestEmail() .build(); // Build the api client. mApiClient = new GoogleApiClient.Builder(this) .addApi(Games.API) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .addConnectionCallbacks(this) .build(); } @Override public void onConnected(Bundle connectionHint) { if (mApiClient.hasConnectedApi(Games.API)) { Auth.GoogleSignInApi.silentSignIn(mApiClient).setResultCallback( new ResultCallback() { @Override public void onResult(GoogleSignInResult googleSignInResult) { // In this case, we are sure the result is a success. GoogleSignInAccount acct = googleSignInResult.getGoogleSignInAccount()); // For Games with a server, send the auth code to your server. String serverAuthCode = signInAccount.getServerAuthCode(); // Use the API client as normal. Player player = Games.API.getCurrentPlayer(mApiClient); } } ); } else { onSignedOut(); } }
List of APIs that are deprecated by removing Google+ integration (and their C++ equivalents):
We realize this is a large change, but moving forward Play Game Services are much better aligned with the rest of the Mobile platform from Google and will lead to better developer experience for Android game developers.