Search in sources :

Example 1 with GoogleSignInResult

use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project SeriesGuide by UweTrottmann.

the class CloudSetupFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        handleSignInResult(result);
    }
}
Also used : GoogleSignInResult(com.google.android.gms.auth.api.signin.GoogleSignInResult)

Example 2 with GoogleSignInResult

use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project SeriesGuide by UweTrottmann.

the class HexagonTools method checkSignInState.

private void checkSignInState() {
    if (credential.getSelectedAccount() != null && !isTimeForSignInStateCheck()) {
        Timber.d("%s: just checked state, skip", ACTION_SILENT_SIGN_IN);
    }
    lastSignInCheck = SystemClock.elapsedRealtime();
    if (googleApiClient == null) {
        googleApiClient = new GoogleApiClient.Builder(app).addApi(Auth.GOOGLE_SIGN_IN_API, getGoogleSignInOptions()).build();
    }
    android.accounts.Account account = null;
    ConnectionResult connectionResult = googleApiClient.blockingConnect();
    if (connectionResult.isSuccess()) {
        OptionalPendingResult<GoogleSignInResult> pendingResult = Auth.GoogleSignInApi.silentSignIn(googleApiClient);
        GoogleSignInResult result = pendingResult.await();
        if (result.isSuccess()) {
            GoogleSignInAccount signInAccount = result.getSignInAccount();
            if (signInAccount != null) {
                Timber.i("%s: successful", ACTION_SILENT_SIGN_IN);
                account = signInAccount.getAccount();
                credential.setSelectedAccount(account);
            } else {
                trackSignInFailure(ACTION_SILENT_SIGN_IN, "GoogleSignInAccount is null");
            }
        } else {
            trackSignInFailure(ACTION_SILENT_SIGN_IN, result.getStatus());
        }
        googleApiClient.disconnect();
    } else {
        trackSignInFailure(ACTION_SILENT_SIGN_IN, connectionResult);
    }
    boolean shouldFixAccount = account == null;
    PreferenceManager.getDefaultSharedPreferences(app).edit().putBoolean(HexagonSettings.KEY_SHOULD_VALIDATE_ACCOUNT, shouldFixAccount).apply();
}
Also used : GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) ConnectionResult(com.google.android.gms.common.ConnectionResult) GoogleSignInResult(com.google.android.gms.auth.api.signin.GoogleSignInResult)

Example 3 with GoogleSignInResult

use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project RSAndroidApp by RailwayStations.

the class SignInActivity 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);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);
        } else {
            // Google Sign In failed
            Log.e(TAG, "Google Sign In failed.");
        }
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) GoogleSignInResult(com.google.android.gms.auth.api.signin.GoogleSignInResult)

Example 4 with GoogleSignInResult

use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project easy by MehdiBenmesa.

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

Example 5 with GoogleSignInResult

use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project easy by MehdiBenmesa.

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

Aggregations

GoogleSignInResult (com.google.android.gms.auth.api.signin.GoogleSignInResult)38 GoogleSignInAccount (com.google.android.gms.auth.api.signin.GoogleSignInAccount)12 IOException (java.io.IOException)3 Bundle (android.os.Bundle)2 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)2 OptionalPendingResult (com.google.android.gms.common.api.OptionalPendingResult)2 PushSocialPayload (org.wordpress.android.fluxc.store.AccountStore.PushSocialPayload)2 Intent (android.content.Intent)1 Uri (android.net.Uri)1 NonNull (android.support.annotation.NonNull)1 View (android.view.View)1 ServerStatusCode (cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode)1 BackendlessUser (com.backendless.BackendlessUser)1 IntentResultListener (com.codename1.impl.android.IntentResultListener)1 AccessToken (com.codename1.io.AccessToken)1 ConnectionRequest (com.codename1.io.ConnectionRequest)1 JSONParser (com.codename1.io.JSONParser)1 GoogleAuthException (com.google.android.gms.auth.GoogleAuthException)1 UserRecoverableAuthException (com.google.android.gms.auth.UserRecoverableAuthException)1 GoogleSignInOptions (com.google.android.gms.auth.api.signin.GoogleSignInOptions)1