Search in sources :

Example 26 with GoogleSignInAccount

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);
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) ApiException(com.google.android.gms.common.api.ApiException)

Example 27 with GoogleSignInAccount

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);
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) Scope(com.google.android.gms.common.api.Scope)

Example 28 with GoogleSignInAccount

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);
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) ApiException(com.google.android.gms.common.api.ApiException)

Example 29 with GoogleSignInAccount

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);
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) Scope(com.google.android.gms.common.api.Scope)

Example 30 with GoogleSignInAccount

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);
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) ApiException(com.google.android.gms.common.api.ApiException)

Aggregations

GoogleSignInAccount (com.google.android.gms.auth.api.signin.GoogleSignInAccount)48 ApiException (com.google.android.gms.common.api.ApiException)15 GoogleSignInResult (com.google.android.gms.auth.api.signin.GoogleSignInResult)12 Intent (android.content.Intent)7 IOException (java.io.IOException)5 User (com.androidstudy.andelamedmanager.data.model.User)2 GoogleSignInOptions (com.google.android.gms.auth.api.signin.GoogleSignInOptions)2 Scope (com.google.android.gms.common.api.Scope)2 Request (okhttp3.Request)2 JSONException (org.json.JSONException)2 Context (android.content.Context)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 NonNull (androidx.annotation.NonNull)1 ServerStatusCode (cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode)1 Response (com.android.volley.Response)1 VolleyError (com.android.volley.VolleyError)1 IntentResultListener (com.codename1.impl.android.IntentResultListener)1 AccessToken (com.codename1.io.AccessToken)1 ConnectionRequest (com.codename1.io.ConnectionRequest)1