use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project iosched by google.
the class SwitchUserActivity method onActivityResult.
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project google-services by googlesamples.
the class IdTokenActivity method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_GET_TOKEN) {
// [START get_id_token]
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
Log.d(TAG, "onActivityResult:GET_TOKEN:success:" + result.getStatus().isSuccess());
if (result.isSuccess()) {
String idToken = result.getSignInAccount().getIdToken();
// TODO(developer): send token to server and validate
}
// [END get_id_token]
handleSignInResult(result);
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project google-services by googlesamples.
the class IdTokenActivity method refreshIdToken.
private void refreshIdToken() {
OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
if (opr.isDone()) {
// Users cached credentials are valid, GoogleSignInResult containing ID token
// is available immediately. This likely means the current ID token is already
// fresh and can be sent to your server.
GoogleSignInResult result = opr.get();
handleSignInResult(result);
} else {
// If the user has not previously signed in on this device or the sign-in has expired,
// this asynchronous branch will attempt to sign in the user silently and get a valid
// ID token. Cross-device single sign on will occur in this branch.
opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
@Override
public void onResult(@NonNull GoogleSignInResult result) {
handleSignInResult(result);
}
});
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project google-services by googlesamples.
the class RestApiActivity method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
}
// Handling a user-recoverable auth exception
if (requestCode == RC_RECOVERABLE) {
if (resultCode == RESULT_OK) {
getContacts();
} else {
Toast.makeText(this, R.string.msg_contacts_failed, Toast.LENGTH_SHORT).show();
}
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project google-services by googlesamples.
the class RestApiActivity method onStart.
@Override
public void onStart() {
super.onStart();
OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
if (opr.isDone()) {
// If the user's cached credentials are valid, the OptionalPendingResult will be "done"
// and the GoogleSignInResult will be available instantly.
Log.d(TAG, "Got cached sign-in");
GoogleSignInResult result = opr.get();
handleSignInResult(result);
} else {
// If the user has not previously signed in on this device or the sign-in has expired,
// this asynchronous branch will attempt to sign in the user silently. Cross-device
// single sign-on will occur in this branch.
showProgressDialog();
opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
@Override
public void onResult(GoogleSignInResult googleSignInResult) {
hideProgressDialog();
handleSignInResult(googleSignInResult);
}
});
}
}
Aggregations