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.

No comments:

Post a Comment