use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project google-services by googlesamples.
the class IdTokenActivity method handleSignInResult.
// [START handle_sign_in_result]
private void handleSignInResult(@NonNull Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
String idToken = account.getIdToken();
// TODO(developer): send ID Token to server and validate
updateUI(account);
} catch (ApiException e) {
Log.w(TAG, "handleSignInResult:error", e);
updateUI(null);
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project google-services by googlesamples.
the class RestApiActivity method onStart.
@Override
public void onStart() {
super.onStart();
// Check if the user is already signed in and all required scopes are granted
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
if (GoogleSignIn.hasPermissions(account, new Scope(CONTACTS_SCOPE))) {
updateUI(account);
} else {
updateUI(null);
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project google-services by googlesamples.
the class SignInActivity method handleSignInResult.
// [END onActivityResult]
// [START handleSignInResult]
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
// Signed in successfully, show authenticated UI.
updateUI(account);
} catch (ApiException e) {
// The ApiException status code indicates the detailed failure reason.
// Please refer to the GoogleSignInStatusCodes class reference for more information.
Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
updateUI(null);
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project google-services by googlesamples.
the class SignInActivityWithDrive method onStart.
@Override
public void onStart() {
super.onStart();
// Check if the user is already signed in and all required scopes are granted
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
if (account != null && GoogleSignIn.hasPermissions(account, new Scope(Scopes.DRIVE_APPFOLDER))) {
updateUI(account);
} else {
updateUI(null);
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project google-services by googlesamples.
the class SignInActivityWithDrive method handleSignInResult.
// [END onActivityResult]
// [START handleSignInResult]
private void handleSignInResult(@Nullable Task<GoogleSignInAccount> completedTask) {
Log.d(TAG, "handleSignInResult:" + completedTask.isSuccessful());
try {
// Signed in successfully, show authenticated U
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
updateUI(account);
} catch (ApiException e) {
// Signed out, show unauthenticated UI.
Log.w(TAG, "handleSignInResult:error", e);
updateUI(null);
}
}
Aggregations