com.google.android.gms.auth.api.signin.GoogleSignInResult Java Examples

The following examples show how to use com.google.android.gms.auth.api.signin.GoogleSignInResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoginActivity.java    From android with MIT License 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if ((requestCode == Const.RequestCodes.AUTH_LOGIN_EMAIL)
            && (resultCode == Activity.RESULT_OK)) {
        setResult(Activity.RESULT_OK);
        this.finish();
    } else if (requestCode == Const.RequestCodes.AUTH_LOGIN_FACEBOOK) {
        facebookCallbackManager.onActivityResult(requestCode, resultCode, data);
    } else if (requestCode == Const.RequestCodes.AUTH_LOGIN_GOOGLE) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        handleGoogleSignInResult(result);
    } else if (requestCode == Const.RequestCodes.AUTH_LOGIN_GOOGLE_RESOLVE) {
        Log.v(TAG, "onActivityResult() google resolve");
    }
}
 
Example #2
Source File: Home.java    From UberClone with MIT License 6 votes vote down vote up
private void verifyGoogleAccount() {
    GoogleSignInOptions gso=new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build();
    mGoogleApiClient=new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
    OptionalPendingResult<GoogleSignInResult> opr=Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()){
        GoogleSignInResult result= opr.get();
        handleSignInResult(result);
    }else {
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
 
Example #3
Source File: SignInController.java    From PGSGP with MIT License 6 votes vote down vote up
public void onSignInActivityResult(GoogleSignInResult googleSignInResult) {
    if (googleSignInResult != null && googleSignInResult.isSuccess()) {
        GoogleSignInAccount googleSignInAccount = googleSignInResult.getSignInAccount();
        String accId = "";
        if (googleSignInAccount != null && googleSignInAccount.getId() != null) {
        	accId = googleSignInAccount.getId();
        }
        enablePopUps();
        godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.SIGNIN_SUCCESSFUL, new Object[]{accId});
    } else {
    	int statusCode = Integer.MIN_VALUE;
    	if (googleSignInResult != null && googleSignInResult.getStatus() != null){
    		statusCode = googleSignInResult.getStatus().getStatusCode();
    	}
        godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.SIGNIN_FAILED, new Object[]{statusCode});
    }
}
 
Example #4
Source File: Home.java    From UberClone with MIT License 6 votes vote down vote up
private void handleSignInResult(GoogleSignInResult result) {
    if (result.isSuccess()) {
        account = result.getSignInAccount();
        Common.userID=account.getId();
        loadUser();
    }else if(isLoggedInFacebook){
        GraphRequest request = GraphRequest.newMeRequest(
                accessToken,
                new GraphRequest.GraphJSONObjectCallback() {
                    @Override
                    public void onCompleted(JSONObject object, GraphResponse response) {
                        String id=object.optString("id");
                        Common.userID=id;
                        loadUser();
                    }
                });
        request.executeAsync();
    }else{
        Common.userID=FirebaseAuth.getInstance().getCurrentUser().getUid();
        loadUser();
    }
}
 
Example #5
Source File: DriverHome.java    From UberClone with MIT License 6 votes vote down vote up
private void handleSignInResult(GoogleSignInResult result) {
    if (result.isSuccess()) {
        account = result.getSignInAccount();
        Common.userID=account.getId();
        loadUser();
    }else if(isLoggedInFacebook){
        GraphRequest request = GraphRequest.newMeRequest(
                accessToken,
                new GraphRequest.GraphJSONObjectCallback() {
                    @Override
                    public void onCompleted(JSONObject object, GraphResponse response) {
                        String id=object.optString("id");
                        Common.userID=id;
                        loadUser();
                    }
                });
        request.executeAsync();
    }else{
        Common.userID=FirebaseAuth.getInstance().getCurrentUser().getUid();
        loadUser();
    }
}
 
Example #6
Source File: SignIn.java    From easygoogle with Apache License 2.0 6 votes vote down vote up
@Override
public void onStart() {
    super.onStart();

    // Kick off silent sign-in process
    Auth.GoogleSignInApi.silentSignIn(getFragment().getGoogleApiClient())
            .setResultCallback(new ResultCallback<GoogleSignInResult>() {
                @Override
                public void onResult(GoogleSignInResult googleSignInResult) {
                    if (googleSignInResult.isSuccess()) {
                        getListener().onSignedIn(googleSignInResult.getSignInAccount());
                    } else {
                        getListener().onSignInFailed();
                    }
                }
            });
}
 
Example #7
Source File: MainActivity.java    From stitch-examples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_SIGN_IN) {
        final GoogleSignInResult result = GoogleSignInApi.getSignInResultFromIntent(data);
        handleGooglSignInResult(result);
        return;
    }

    if (_callbackManager != null) {
        _callbackManager.onActivityResult(requestCode, resultCode, data);
        return;
    }
    Log.e(TAG, "Nowhere to send activity result for ourselves");
}
 
Example #8
Source File: MainActivity.java    From stitch-examples with Apache License 2.0 6 votes vote down vote up
private void handleGooglSignInResult(final GoogleSignInResult result) {
    if (result == null) {
        Log.e(TAG, "Got a null GoogleSignInResult");
        return;
    }

    Log.d(TAG, "handleGooglSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        final GoogleCredential googleCredential = new GoogleCredential(result.getSignInAccount().getServerAuthCode());
        _client.getAuth().loginWithCredential(googleCredential).addOnCompleteListener(new OnCompleteListener<StitchUser>() {
            @Override
            public void onComplete(@NonNull final Task<StitchUser> task) {
                if (task.isSuccessful()) {
                    initTodoView();
                } else {
                    Log.e(TAG, "Error logging in with Google", task.getException());
                }
            }
        });
    }
}
 
Example #9
Source File: MainActivity.java    From stitch-examples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_SIGN_IN) {
        final GoogleSignInResult result = GoogleSignInApi.getSignInResultFromIntent(data);
        handleGooglSignInResult(result);
        return;
    }

    if (_callbackManager != null) {
        _callbackManager.onActivityResult(requestCode, resultCode, data);
        return;
    }
    Log.e(TAG, "Nowhere to send activity result for ourselves");
}
 
Example #10
Source File: MainActivity.java    From stitch-examples with Apache License 2.0 6 votes vote down vote up
private void handleGooglSignInResult(final GoogleSignInResult result) {
    if (result == null) {
        Log.e(TAG, "Got a null GoogleSignInResult");
        return;
    }

    Log.d(TAG, "handleGooglSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        final GoogleCredential googleCredential = new GoogleCredential(result.getSignInAccount().getServerAuthCode());
        _client.getAuth().loginWithCredential(googleCredential).addOnCompleteListener(new OnCompleteListener<StitchUser>() {
            @Override
            public void onComplete(@NonNull final Task<StitchUser> task) {
                if (task.isSuccessful()) {
                    initTodoView();
                } else {
                    Log.e(TAG, "Error logging in with Google", task.getException());
                }
            }
        });
    } else {
        Toast.makeText(MainActivity.this, "Failed to log on using Google. Result: " + result.getStatus(), Toast.LENGTH_LONG).show();
    }
}
 
Example #11
Source File: Fido2DemoActivity.java    From android-fido with Apache License 2.0 6 votes vote down vote up
private void handleSignInResult(GoogleSignInResult result) {
    Log.d(TAG, "handleSignInResult:" + result.isSuccess());
    Log.d(TAG, "sign in result: " + result.getStatus().toString());
    if (result.isSuccess()) {
        GoogleSignInAccount acct = result.getSignInAccount();
        saveAccountSignInStatus();
        Log.d(TAG, "account email" + acct.getEmail());
        Log.d(TAG, "account displayName" + acct.getDisplayName());
        Log.d(TAG, "account id" + acct.getId());
        Log.d(TAG, "account idToken" + acct.getIdToken());
        Log.d(TAG, "account scopes" + acct.getGrantedScopes());
    } else {
        clearAccountSignInStatus();
    }
    updateUI();
}
 
Example #12
Source File: GoogleSign.java    From FeedFire with MIT License 6 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent 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, update UI appropriately
            // [START_EXCLUDE]
            mGoogleCallback.loginFailed();
            // [END_EXCLUDE]
        }
    }
}
 
Example #13
Source File: SplashActivity.java    From FChat with MIT License 6 votes vote down vote up
@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()) {
            signInButton.setVisibility(View.GONE);
            loginProgress.setVisibility(View.VISIBLE);
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);
        } else {
            customToast.showError(getString(R.string.error_login_failed));
        }
    }
}
 
Example #14
Source File: SignInBaseActivity.java    From Expert-Android-Programming with MIT License 6 votes vote down vote up
@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 {
        callbackManager.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example #15
Source File: LoginPresenter.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
public void handleGoogleSignInResult(GoogleSignInResult result) {
    ifViewAttached(view -> {
        if (result.isSuccess()) {
            view.showProgress();

            GoogleSignInAccount account = result.getSignInAccount();

            view.setProfilePhotoUrl(buildGooglePhotoUrl(account.getPhotoUrl()));

            AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
            view.firebaseAuthWithCredentials(credential);

            LogUtil.logDebug(TAG, "firebaseAuthWithGoogle:" + account.getId());

        } else {
            LogUtil.logDebug(TAG, "SIGN_IN_GOOGLE failed :" + result);
            view.hideProgress();
        }
    });
}
 
Example #16
Source File: PlayGameServices.java    From PGSGP with MIT License 6 votes vote down vote up
protected void onMainActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == SignInController.RC_SIGN_IN) {
        GoogleSignInResult googleSignInResult = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        signInController.onSignInActivityResult(googleSignInResult);
    } else if (requestCode == AchievementsController.RC_ACHIEVEMENT_UI || requestCode == LeaderboardsController.RC_LEADERBOARD_UI) {
        Pair<Boolean, String> isConnected = connectionController.isConnected();
        godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.PLAYER_CONNECTED, new Object[]{isConnected.first, isConnected.second});
    } else if (requestCode == SavedGamesController.RC_SAVED_GAMES) {
        if (data != null) {
            if (data.hasExtra(SnapshotsClient.EXTRA_SNAPSHOT_METADATA)) {
                SnapshotMetadata snapshotMetadata = data.getParcelableExtra(SnapshotsClient.EXTRA_SNAPSHOT_METADATA);
                if (snapshotMetadata != null) {
                    savedGamesController.loadSnapshot(snapshotMetadata.getUniqueName());
                }
            } else if (data.hasExtra(SnapshotsClient.EXTRA_SNAPSHOT_NEW)) {
                String unique = new BigInteger(281, new Random()).toString(13);
                String currentSaveName = appActivity.getString(R.string.default_game_name) + unique;

                savedGamesController.createNewSnapshot(currentSaveName);
            }
        }
    }
}
 
Example #17
Source File: LoginActivity.java    From Simple-Blog-App with MIT License 6 votes vote down vote up
@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, update UI appropriately
        }
    }
    callbackManager.onActivityResult(requestCode, resultCode, data);
    twitterLoginButton.onActivityResult(requestCode, resultCode, data);
}
 
Example #18
Source File: UpdateFragment.java    From Android-nRF-Beacon-for-Eddystone with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void handleSilentSignIn(){

        OptionalPendingResult<GoogleSignInResult> pendingResult = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);

        if (pendingResult.isDone()) {
            // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
            // and the GoogleSignInResult will be available instantly.
            Log.d(Utils.TAG, "Got cached sign-in");
            GoogleSignInResult result = pendingResult.get();
            handleSignInResult(result);
        } else {
            pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
                @Override
                public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                    handleSignInResult(googleSignInResult);
                }
            });
        }
    }
 
Example #19
Source File: UpdateFragment.java    From Android-nRF-Beacon-for-Eddystone with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void handleSignInResult(GoogleSignInResult result) {
    Log.d(Utils.TAG, "handleSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        mSilentSignInFailed = false;
        // Signed in successfully, show authenticated UI.
        GoogleSignInAccount acct = result.getSignInAccount();
        mServerAuthCode = acct.getServerAuthCode();
        if(!checkIfAccessTokenExists()) {
            if (!Utils.UTILS_CLIENT_ID.equals(getString(R.string.server_client_id))) {
                new RequestAccessTokenTask(getActivity(), mRequestAccessTokenCallback, "https://www.googleapis.com/oauth2/v4/token", getString(R.string.server_client_id), acct.getServerAuthCode()).execute();
            } else {
                showToast(getString(R.string.error_server_client_id));
            }
        }
    } else {
        mSilentSignInFailed = true;
    }
}
 
Example #20
Source File: SignIn.java    From easygoogle with Apache License 2.0 6 votes vote down vote up
@Override
public boolean handleActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RC_SIGN_IN) {
        if (data != null) {
            GoogleSignInResult gsr = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
            if (gsr != null && gsr.isSuccess()) {
                getListener().onSignedIn(gsr.getSignInAccount());
            } else {
                getListener().onSignInFailed();
            }
        }

        return true;
    }

    return false;
}
 
Example #21
Source File: GoogleLoginHiddenActivity.java    From SocialLoginManager with Apache License 2.0 6 votes vote down vote up
private void handleSignInResult(GoogleSignInResult result) {
  if (result.isSuccess()) {
    GoogleSignInAccount acct = result.getSignInAccount();
    SocialUser user = new SocialUser();
    user.userId = acct.getId();
    user.accessToken = acct.getIdToken();
    user.photoUrl = acct.getPhotoUrl() != null ? acct.getPhotoUrl().toString() : "";
    SocialUser.Profile profile = new SocialUser.Profile();
    profile.email = acct.getEmail();
    profile.name = acct.getDisplayName();
    user.profile = profile;
    SocialLoginManager.getInstance(this).onLoginSuccess(user);
  } else {
    Throwable throwable = new Throwable(result.getStatus().getStatusMessage());
    SocialLoginManager.getInstance(this).onLoginError(throwable);
  }

  finish();
}
 
Example #22
Source File: SignInActivity.java    From jterm-cswithandroid with Apache License 2.0 6 votes vote down vote up
@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.");
        }
    }
}
 
Example #23
Source File: GoogleSignInActivity.java    From endpoints-samples with Apache License 2.0 6 votes vote down vote up
@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, update UI appropriately
            // [START_EXCLUDE]
            updateUI(null);
            // [END_EXCLUDE]
        }
    }
}
 
Example #24
Source File: GoogleSignUpAdapter.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@Override public Single<Account> signUp(GoogleSignInResult result, AccountService service) {

    if (!isEnabled()) {
      return Single.error(new IllegalStateException("Google sign up is not enabled"));
    }

    final GoogleSignInAccount account = result.getSignInAccount();
    if (result.isSuccess() && account != null) {
      return service.createAccount(account.getEmail(), account.getServerAuthCode(), "GOOGLE");
    } else {
      return Single.error(new GoogleSignUpException(GoogleSignInStatusCodes.getStatusCodeString(
          result.getStatus()
              .getStatusCode()), result.getStatus()
          .getStatusCode()));
    }
  }
 
Example #25
Source File: LoginActivity.java    From FaceT with Mozilla Public License 2.0 6 votes vote down vote up
@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);

            mProgress.setMessage("Starting Sign in ...");
            mProgress.show();

            if (result.isSuccess()) {
                // Google Sign In was successful, authenticate with Firebase
                GoogleSignInAccount account = result.getSignInAccount();
                firebaseAuthWithGoogle(account);
//                successDialog("Login Successful", " Welcome to FaceT =] ");
            } else {
                // Google Sign In failed, update UI appropriately
                // ...
                mProgress.dismiss();
            }
        }

        mCallbackManager.onActivityResult(requestCode, resultCode, data);
    }
 
Example #26
Source File: Loginactivity.java    From LuxVilla with Apache License 2.0 6 votes vote down vote up
@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 {
            linearLayout.setVisibility(View.VISIBLE);
            layoutprogressbar.setVisibility(View.GONE);
            Snackbar.make(linearLayout,"Ocorreu um erro ao conectar", Snackbar.LENGTH_LONG).show();
        }
    }
}
 
Example #27
Source File: RegisterActivity.java    From kute with Apache License 2.0 6 votes vote down vote up
@Override
protected 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.");
        }
    }
    else{
        mCallbackManager.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example #28
Source File: GoogleLogin.java    From Android-Smart-Login with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data, SmartLoginConfig config) {
    ProgressDialog progress = ProgressDialog.show(config.getActivity(), "", config.getActivity().getString(R.string.getting_data), true);
    GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
    Log.d("GOOGLE SIGN IN", "handleSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        // Signed in successfully, show authenticated UI.
        GoogleSignInAccount acct = result.getSignInAccount();
        SmartGoogleUser googleUser = UserUtil.populateGoogleUser(acct);
        // Save the user
        UserSessionManager.setUserSession(config.getActivity(), googleUser);
        config.getCallback().onLoginSuccess(googleUser);
        progress.dismiss();
    } else {
        Log.d("GOOGLE SIGN IN", "" + requestCode);
        // Signed out, show unauthenticated UI.
        progress.dismiss();
        config.getCallback().onLoginFailure(new SmartLoginException("Google login failed", LoginType.Google));
    }
}
 
Example #29
Source File: LoginPresenter.java    From FastAccess with GNU General Public License v3.0 6 votes vote down vote up
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == SIGN_IN_REQUEST_CODE) {
        if (isAttached()) {
            GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
            if (result.isSuccess()) {
                GoogleSignInAccount account = result.getSignInAccount();
                if (account != null) {
                    getView().onSignedIn(account);
                } else {
                    getView().onShowMessage(R.string.failed_login);
                }
            } else {
                getView().onShowMessage(R.string.failed_login);
            }
        }
    }

}
 
Example #30
Source File: MainActivity.java    From friendspell with Apache License 2.0 6 votes vote down vote up
@Override
public void onConnected(Bundle connectionHint) {
  Timber.d("onConnected");
  if (shouldAutoLogin) {
    OptionalPendingResult<GoogleSignInResult> pendingResult =
            googleApiClientBridge.silentSignIn(googleApiClientToken);
    if (pendingResult.isDone()) {
      // There's immediate result available.
      handleSignInResult(pendingResult.get());
    } else {
      // There's no immediate result ready
      pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
        @Override
        public void onResult(@NonNull GoogleSignInResult result) {
          handleSignInResult(result);
        }
      });
    }
  }
}