Search in sources :

Example 31 with GoogleSignInResult

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

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

Example 32 with GoogleSignInResult

use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project Android-SDK by Backendless.

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

Example 33 with GoogleSignInResult

use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project Passenger_Security by ujjwalagr.

the class GoogleLogin method onActivityResult.

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

Example 34 with GoogleSignInResult

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

the class SignInManager method onActivityResult.

/**
 * Method for processing sign in logic in the bonding activity's
 * {@link Activity#onActivityResult(int, int, Intent)}.
 *
 * @param requestCode The requestCode argument of the activity's onActivityResult.
 * @param resultCode  The resultCode argument of the activity's onActivityResult.
 * @param data        The Intent argument of the activity's onActivityResult.
 */
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    final SignInListener signInListener = getSignInListener();
    if (signInListener == null) {
        return;
    }
    if (requestCode == AccountUtils.RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            GoogleSignInAccount acct = result.getSignInAccount();
            if (acct != null) {
                performPostSignInTasks(acct, result);
            }
        } else {
            LOGW(TAG, "Sign in failed");
            signInListener.onSignInFailed(result);
        }
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) GoogleSignInResult(com.google.android.gms.auth.api.signin.GoogleSignInResult)

Example 35 with GoogleSignInResult

use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project androidApp by InspectorIncognito.

the class GoogleAccountLoader method load.

@Override
public void load(final CredentialsListener listener) {
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().requestIdToken(TranSappApplication.getAppContext().getString(R.string.server_client_id)).build();
    final GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(TranSappApplication.getAppContext()).addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
    mGoogleApiClient.registerConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {

        @Override
        public void onConnected(@Nullable Bundle bundle) {
            OptionalPendingResult<GoogleSignInResult> pendingResult = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
            if (pendingResult.isDone()) {
                loadDataFromSignInResult(pendingResult.get(), listener, mGoogleApiClient);
            } else {
                pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {

                    @Override
                    public void onResult(@NonNull GoogleSignInResult result) {
                        if (result.isSuccess()) {
                            loadDataFromSignInResult(result, listener, mGoogleApiClient);
                        } else {
                            listener.onError(new ServerStatusCode(LOGIN_API_ERROR));
                        }
                    }
                }, 5000, TimeUnit.MILLISECONDS);
            }
        }

        @Override
        public void onConnectionSuspended(int i) {
            listener.onError(new ServerStatusCode(LOGIN_API_ERROR));
        }
    });
    mGoogleApiClient.connect();
}
Also used : GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) ResultCallback(com.google.android.gms.common.api.ResultCallback) Bundle(android.os.Bundle) ServerStatusCode(cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode) OptionalPendingResult(com.google.android.gms.common.api.OptionalPendingResult) GoogleSignInResult(com.google.android.gms.auth.api.signin.GoogleSignInResult) NonNull(android.support.annotation.NonNull) GoogleSignInOptions(com.google.android.gms.auth.api.signin.GoogleSignInOptions)

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 Intent (android.content.Intent)1 Uri (android.net.Uri)1 NonNull (android.support.annotation.NonNull)1 ServerStatusCode (cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode)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 ConnectionResult (com.google.android.gms.common.ConnectionResult)1 OptionalPendingResult (com.google.android.gms.common.api.OptionalPendingResult)1 ResultCallback (com.google.android.gms.common.api.ResultCallback)1 GsonBuilder (com.google.gson.GsonBuilder)1