Friday, December 16, 2016

Games authentication adopting Google Sign-In API


Posted by Clayton Wilkinson, Developer Platform Engineer



Some changes are coming to Play Game Services in early 2017:


Changes to Google API Client building



In November, we announced an href="https://developers.googleblog.com/2016/11/moving-to-google-sign-in-for-a-better-user-experience-and-higher-conversion-rates.html">update
to Google Sign-In API. Play Game Services is being updated to use Google
Sign-In API for authentication. The advantages are:


  • Games and Sign-In in same client connection.
  • Single API for getting Auth code to send to backend servers.


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:



class="prettyprint">// 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();
}
}

Account creation within iOS is no longer supported



  • Currently, there is no support for new players to create a Play Games
    account on iOS. Additionally, the Google+ integration has been removed from
    iOS. As a result "social" APIs will return result codes indicating success, but
    return empty lists. This includes the "standard" UIs for leaderboards and
    multiplayer invitations.

Google+ is no longer integrated



  • href="http://android-developers.blogspot.com/2016/01/play-games-permissions-are-changing-in.html">Announced
    last year, Games is decoupled from Google+ during this transition. As a
result the public APIs for getting connected players via circles stopped
working, but the standard UIs for multiplayer invitations and social
leaderboards continued to work. Starting from February 2017, the standard UIs
will also not display the Social graph results as Google+ data becomes
inaccessible. This will affect multiplayer games, social leaderboards, and
gifts API on Android. The effect will be that these APIs will return
successfully, but with an empty list of players.


List of APIs that are deprecated by removing Google+ integration (and their C++
equivalents):


  1. href="https://developers.google.com/android/reference/com/google/android/gms/games/Players.html?utm_campaign=product area_discussion_games_121616&utm_source=anddev&utm_medium=blog#getPlayerSearchIntent(com.google.android.gms.common.api.GoogleApiClient)">Games.Players.getPlayerSearchIntent()
  2. href="https://developers.google.com/android/reference/com/google/android/gms/games/Players.html?utm_campaign=product area_discussion_games_121616&utm_source=anddev&utm_medium=blog#loadConnectedPlayers(com.google.android.gms.common.api.GoogleApiClient,%20boolean)">Games.Players.loadConnectedPlayers()
  3. href="https://developers.google.com/android/reference/com/google/android/gms/games/Players.html?utm_campaign=product area_discussion_games_121616&utm_source=anddev&utm_medium=blog#loadInvitablePlayers(com.google.android.gms.common.api.GoogleApiClient,%20int,%20boolean)">Games.Players.loadInvitablePlayers()
  4. The value href="https://developers.google.com/android/reference/com/google/android/gms/games/leaderboard/LeaderboardVariant.html?utm_campaign=product area_discussion_games_121616&utm_source=anddev&utm_medium=blog#COLLECTION_SOCIAL">LeaderboardVariant.COLLECTION_SOCIAL
  5. href="https://developers.google.com/android/reference/com/google/android/gms/games/multiplayer/Invitations.html?utm_campaign=product area_discussion_games_121616&utm_source=anddev&utm_medium=blog#loadInvitations(com.google.android.gms.common.api.GoogleApiClient,%20int)">Invitations.loadInvitations()
  6. href="https://developers.google.com/android/reference/com/google/android/gms/games/multiplayer/realtime/RealTimeMultiplayer.html?utm_campaign=product area_discussion_games_121616&utm_source=anddev&utm_medium=blog#getSelectOpponentsIntent(com.google.android.gms.common.api.GoogleApiClient,%20int,%20int,%20boolean)">RealtimeMultiplayer.getSelectOpponentsIntent()
  7. href="https://developers.google.com/android/reference/com/google/android/gms/games/multiplayer/turnbased/TurnBasedMultiplayer.html?utm_campaign=product area_discussion_games_121616&utm_source=anddev&utm_medium=blog#getSelectOpponentsIntent(com.google.android.gms.common.api.GoogleApiClient,%20int,%20int,%20boolean)">TurnBasedMultiplayer.getSelectOpponentsIntent()
  8. All methods in the href="https://developers.google.com/android/reference/com/google/android/gms/games/request/GameRequest?utm_campaign=product area_discussion_games_121616&utm_source=anddev&utm_medium=blog">Requests
    package.


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.

  • Why Writing Copy for Your Own Business Can Backfire Copywriting is essential for all business. While copywriting alone will not determine your success, the lack of that can certainly spell your early demise. The problem for most is that while copywriting is a phrase most business professionals…
  • Toyota Evaporative Emissions Greetings fellow Toyota owners! Is your check engine light on? Do you have the famous p0440, p0441 or p0446 stored in your computer? Well you're in luck! I am going to talk a little about this problem Toyota has been having, how to fix it,…
  • How to File a Nail Without a Nail File Do not you hate it when you break or snag a finger nail? It's annoying and dangerous. Anyone that has cut their nose with a rough nail knows this. Do not even go near your eye - ouch! No file - no problem. I learned years ago how to take…
  • Some of the Best Ideas On Making Money Through Affiliate Marketing If you are not sure what direction to go in with affiliate marketing, then you want to start learning as many tips as possible. People seem to become more focused and have an idea with what they want on their sites when they understand ways they…
  • What Makes One Human Different From One Another?There are so many people sharing and living this world together in different places. We recognize them from where they come from, in this case are the countries they live in or maybe the nationality they have. We also notice that different people…