com.google.android.gms.auth.api.signin.GoogleSignInApi |
Api interface for Sign In with Google.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets an
Intent to start the Google Sign In flow by calling
startActivityForResult(Intent, int) .
| |||||||||||
Helper function to extract out
GoogleSignInResult from the
onActivityResult(int, int, Intent) for Sign In.
| |||||||||||
Revokes access given to the current application.
| |||||||||||
Signs out the current signed-in user if any.
| |||||||||||
Returns the
GoogleSignInAccount information for the user who is signed in to this
app.
|
Gets an Intent
to start the Google Sign In flow by calling
startActivityForResult(Intent, int)
.
client | The GoogleApiClient to service the call. |
---|
Intent
used for start the sign-in flow.
Helper function to extract out GoogleSignInResult
from the
onActivityResult(int, int, Intent)
for Sign In.
data | the Intent returned on onActivityResult(int, int, Intent) when
sign in completed. |
---|
GoogleSignInResult
object. Make sure to pass the Intent
you get
back from onActivityResult(int, int, Intent)
for Sign In, otherwise result
will be null.
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.
client | The connected GoogleApiClient to service the call. |
---|
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.
client | The connected GoogleApiClient to service the call. |
---|
Returns the 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 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:
client | The GoogleApiClient to service the call. |
---|
OptionalPendingResult
that will yield a GoogleSignInResult
. Check for
an immediate result with isDone()
; or set a callback to
handle asynchronous results.