This interface is deprecated.
Use Credential
Manager for authentication or Google Identity
Services for authorization.
Api interface for Sign In with Google.
Constant Summary
String | EXTRA_SIGN_IN_ACCOUNT | String Intent
extra key for getting the SignInAccount from the Intent
data returned on
Activity.onActivityResult(int, int, Intent) when sign-in succeeded. |
Public Method Summary
abstract Intent |
getSignInIntent(GoogleApiClient
client)
Gets an
Intent
to start the Google Sign In flow by calling
Activity.startActivityForResult(Intent, int) .
|
abstract GoogleSignInResult |
getSignInResultFromIntent(Intent data)
Helper function to extract out
GoogleSignInResult from the
Activity.onActivityResult(int, int, Intent) for Sign In.
|
abstract PendingResult<Status> | |
abstract PendingResult<Status> | |
abstract OptionalPendingResult<GoogleSignInResult> |
silentSignIn(GoogleApiClient
client)
Returns the
ERROR(/GoogleSignInAccount)
information for the user who is signed in to this app.
|
Constants
public static final String EXTRA_SIGN_IN_ACCOUNT
String Intent
extra
key for getting the SignInAccount from the Intent
data
returned on
Activity.onActivityResult(int, int, Intent)
when sign-in succeeded.
Public Methods
public abstract Intent getSignInIntent (GoogleApiClient client)
Gets an Intent
to
start the Google Sign In flow by calling
Activity.startActivityForResult(Intent, int)
.
Parameters
client | The GoogleApiClient
to service the call. |
---|
Returns
- the
Intent
used for start the sign-in flow.
public abstract GoogleSignInResult getSignInResultFromIntent (Intent data)
Helper function to extract out GoogleSignInResult
from the
Activity.onActivityResult(int, int, Intent)
for Sign In.
Parameters
data | the Intent
returned on
Activity.onActivityResult(int, int, Intent) when sign in completed. |
---|
Returns
- The
GoogleSignInResult
object. Make sure to pass theIntent
you get back fromActivity.onActivityResult(int, int, Intent)
for Sign In, otherwise result will be null.
public abstract PendingResult<Status> revokeAccess (GoogleApiClient client)
Revokes access given to the current application. Future sign-in attempts will require the user to re-consent to all requested scopes. Applications are required to provide users that are signed in with Google the ability to disconnect their Google account from the app. If the user deletes their account, you must delete the information that your app obtained from the Google APIs.
Parameters
client | The connected GoogleApiClient
to service the call. |
---|
Returns
- the PendingResult for notification and access to the result when it's available.
public abstract PendingResult<Status> signOut (GoogleApiClient client)
Signs out the current signed-in user if any. It also clears the account previously selected by the user and a future sign in attempt will require the user pick an account again.
Parameters
client | The connected GoogleApiClient
to service the call. |
---|
Returns
- the PendingResult for notification and access to the result when it's available.
public abstract OptionalPendingResult<GoogleSignInResult> silentSignIn (GoogleApiClient client)
Returns the ERROR(/GoogleSignInAccount)
information for the user who is signed in to this app. If no user is signed in, try to
sign the user in without displaying any user interface.
Client activities may call the returned
OptionalPendingResult.isDone()
to decide whether to show a loading indicator
and set callbacks to handle an asynchronous result, or directly proceed to the next
step.
A sample usage:
OptionalPendingResult<GoogleSignInResult> pendingResult = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient); if (pendingResult.isDone()) { // There's immediate result available. updateButtonsAndStatusFromSignInResult(pendingResult.get()); } else { // There's no immediate result ready, displays some progress indicator and waits for the // async callback. showProgressIndicator(); pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() { @Override public void onResult(@NonNull GoogleSignInResult result) { updateButtonsAndStatusFromSignInResult(result); hideProgressIndicator(); } }); }
The GoogleSignInResult will possibly contain an ID token which may be used to authenticate and identify sessions that you establish with your application servers. If you use the ID token expiry time to determine your session lifetime, you should retrieve a refreshed ID token, by calling silentSignIn prior to each API call to your application server.
Calling silentSignIn can also help you detect user revocation of access to your
application on other platforms and you can call
getSignInIntent(GoogleApiClient)
again to ask the user to re-authorize.
If your user has never previously signed in to your app on the current device, we can still try to sign them in, without displaying user interface, if they have signed in on a different device.
We attempt to sign users in if:
- There is one and only one matching account on the device that has previously signed in to your application, and
- the user previously granted all of the scopes your app is requesting for this sign in.
Parameters
client | The GoogleApiClient
to service the call. |
---|
Returns
OptionalPendingResult
that will yield aGoogleSignInResult
. Check for an immediate result withOptionalPendingResult.isDone()
; or set a callback to handle asynchronous results.