Search in sources :

Example 21 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(GoogleSignInResult result) {
    Log.d(TAG, "handleSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        // Signed in successfully, show authenticated UI.
        GoogleSignInAccount acct = result.getSignInAccount();
        mStatusTextView.setText(getString(R.string.signed_in_fmt, acct.getDisplayName()));
        updateUI(true);
    } else {
        // Signed out, show unauthenticated UI.
        updateUI(false);
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount)

Example 22 with GoogleSignInAccount

use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project iosched by google.

the class SwitchUserActivity method handleSignInResult.

/**
     * Update active account and inform calling task of result completion.
     * Invoked after after the GoogleSignInApi login process completes (which is itself invoked
     * in SignOutCallback).
     *
     * <p>In the event the user cancels login, the last known user is restored.
     *
     * @param result User data from GoogleSignInApi
     */
private void handleSignInResult(final GoogleSignInResult result) {
    if (result.isSuccess()) {
        final GoogleSignInAccount newUser = result.getSignInAccount();
        if (newUser != null) {
            AccountUtils.setActiveAccount(this, newUser.getEmail());
            LOGI(TAG, "Switched to user: " + newUser);
            setResult(Activity.RESULT_OK);
        }
    } else {
        // Login failed, revert to previous user to simulate spinner behavior
        LOGI(TAG, "Account switch aborted, re-enabling previous user: " + mPreviousUser);
        AccountUtils.setActiveAccount(this, mPreviousUser);
        setResult(Activity.RESULT_CANCELED);
    }
    finish();
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount)

Example 23 with GoogleSignInAccount

use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project iosched by google.

the class AccountFragment method handleSignInResult.

private void handleSignInResult(final GoogleSignInResult result) {
    Log.d(TAG, "handleSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        // Signed in successfully, show authenticated UI.
        final GoogleSignInAccount acct = result.getSignInAccount();
        if (acct != null) {
            AccountUtils.setActiveAccount(getContext(), acct.getEmail());
            doNext();
        }
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount)

Example 24 with GoogleSignInAccount

use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project Android by Tracman-org.

the class LoginActivity method handleGoogleSignInResult.

private void handleGoogleSignInResult(GoogleSignInResult result) {
    //Log.d(TAG, "handleSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        // Signed in successfully
        GoogleSignInAccount acct = result.getSignInAccount();
        try {
            // Build request
            Request request = new Request.Builder().url(SERVER_ADDRESS + "login/app/google?id_token=" + acct.getIdToken()).build();
            // Send to server
            authenticateWithTracmanServer(request);
        } catch (Exception e) {
        //Log.e(TAG, "Error sending ID token to backend.", e);
        }
    } else {
        //Log.e(TAG, "Failed to log in: "+result.getStatus().getStatusCode());
        if (result.getStatus().getStatusCode() != 4) {
            showError(R.string.google_connection_error);
        }
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) Request(okhttp3.Request) JSONException(org.json.JSONException) IOException(java.io.IOException)

Example 25 with GoogleSignInAccount

use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project coins-android by bubelov.

the class SignInActivity method handleSignInResult.

private void handleSignInResult(GoogleSignInResult result) {
    if (result.isSuccess()) {
        GoogleSignInAccount account = result.getSignInAccount();
        new AuthWithGoogleTask(account.getIdToken()).execute();
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount)

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