A client for performing sign-in with Play Games Services.
| abstract Task<AuthenticationResult> |
isAuthenticated()
Returns the current authentication status via an
AuthenticationResult.
|
| abstract Task<String> |
requestServerSideAccess(String
serverClientId, boolean forceRefreshToken)
Requests server-side access to Play Games Services for the currently signed-in
player.
|
| abstract Task<AuthenticationResult> |
signIn()
Manually requests that your game sign in with Play Games Services.
|
Returns the current authentication status via an AuthenticationResult.
If a sign-in flow is currently in progress (such as the automatic sign-in attempt during game start), delivery of this call's result will be postponed until the current sign-in attempt has completed.
This API is useful for understanding if your game has access to Play Games Services. This method should be called when your game starts in order to conditionally enable or disable your Play Games Services integration.
Example usage:
GamesSignInClient gamesSignInClient = PlayGames.getGamesSignInClient(this);
gamesSignInClient.isAuthenticated().addOnCompleteListener(isAuthenticatedTask -> {
if (!isAuthenticatedTask.isSuccessful()) {
// Disable Play Games Services integration
return;
}
AuthenticationResult authenticationResult = isAuthenticatedTask.getResult();
if (!authenticationResult.isAuthenticated()) {
// Disable Play Games Services integration
return;
}
// Enable Play Games Services integration
});
Task providing
an AuthenticationResult
that indicates the current authentication status.Requests server-side access to Play Games Services for the currently signed-in player.
When requested, an authorization code is returned that can be used by your server to
exchange for an access token (and conditionally a refresh token when
forceRefreshToken is true). The access token may then be used
by your server to access the Play Games Services web APIs. This is commonly used to
complete a sign-in flow by verifying the Play Games Services player ID.
If forceRefreshToken is true, when exchanging the
authorization code, a refresh token will be returned in addition to the access token.
The refresh token allows your server to request additional access tokens, allowing your
server to continue accesses Play Games Services while the user is not actively playing
your game. Refresh tokens are only generated for players that have auto sign-in setting
enabled.
| serverClientId | The client ID of the server that will perform the authorization code flow exchange. |
|---|---|
| forceRefreshToken | If true, when the returned authorization code is exchanged, a
refresh token will be included in addition to an access token. |
Task providing
an OAuth 2.0 authorization code as a string. This code can be exchanged by your
server for an access token (and conditionally a refresh token) that can be used to
access the Play Games Services web APIs.Manually requests that your game sign in with Play Games Services.
Note that a sign-in attempt will be made automatically when your game starts. Games will only need to manually request to sign in if the automatic sign-in attempt failed.
Task that
signals the result of the sign-in attempt.