private void handleSignInResult(GoogleSignInResult result){ Log.i("robin", "handleSignInResult:" + result.isSuccess()); if(result.isSuccess()){ Log.i("robin", "成功"); GoogleSignInAccount acct = result.getSignInAccount(); if(acct!=null){ Log.i("robin", "用户名是:" + acct.getDisplayName()); Log.i("robin", "用户email是:" + acct.getEmail()); Log.i("robin", "用户头像是:" + acct.getPhotoUrl()); Log.i("robin", "用户Id是:" + acct.getId());//之后就可以更新UI了 Log.i("robin", "用户IdToken是:" + acct.getIdToken()); tvMsg.setText("用户名是:" + acct.getDisplayName()+"\n用户email是:" + acct.getEmail()+"\n用户头像是:" + acct.getPhotoUrl()+ "\n用户Id是:" + acct.getId()+"\n用户IdToken是:" + acct.getIdToken()); } }else{ tvMsg.setText("登录失败"); Log.i("robin", "没有成功"+result.getStatus()); } }
@Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { String email = account.getEmail(); String name = account.getDisplayName(); String userID = mFirebaseAuth.getCurrentUser().getUid(); boolean newUser = task.getResult().getAdditionalUserInfo().isNewUser(); addNewUser(email, name, "", userID, newUser); } else { Log.w(TAG, task.getException().toString()); Toast.makeText(SigninActivity.this, task.getException().toString(), Toast.LENGTH_SHORT) .show(); } } });
public void signup(int mifosSavingsProductId) { showProgressDialog(Constants.PLEASE_WAIT); Intent intent = new Intent(LoginActivity.this, MobileVerificationActivity.class); intent.putExtra(Constants.MIFOS_SAVINGS_PRODUCT_ID, mMifosSavingProductId); if (account != null) { intent.putExtra(Constants.GOOGLE_PHOTO_URI, account.getPhotoUrl()); intent.putExtra(Constants.GOOGLE_DISPLAY_NAME, account.getDisplayName()); intent.putExtra(Constants.GOOGLE_EMAIL, account.getEmail()); intent.putExtra(Constants.GOOGLE_FAMILY_NAME, account.getFamilyName()); intent.putExtra(Constants.GOOGLE_GIVEN_NAME, account.getGivenName()); } hideProgressDialog(); startActivity(intent); if (googleSignInClient != null) { googleSignInClient.signOut().addOnCompleteListener(this, new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { account = null; } }); } } }
private GoogleAuthUser parseToGoogleUser(GoogleSignInAccount account) { GoogleAuthUser user = new GoogleAuthUser(); user.name = account.getDisplayName(); user.familyName = account.getFamilyName(); user.idToken = account.getIdToken(); user.email = account.getEmail(); user.photoUrl = account.getPhotoUrl(); return user; }
private void handleSignInSuccess(GoogleSignInAccount account) { Toast.makeText(getActivity(), getString(R.string.welcome_user, account.getDisplayName()), Toast.LENGTH_LONG).show(); ((BikestoreApplication) getActivity().getApplication()).login(account.getEmail()); getActivity().setResult(Activity.RESULT_OK); getActivity().finish(); }
String personGivenName = acct.getGivenName(); String personFamilyName = acct.getFamilyName(); String personEmail = acct.getEmail(); String personId = acct.getId(); Uri personPhoto = acct.getPhotoUrl();
private void handleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) { Log.d("G + login success"); GoogleSignInAccount acct = result.getSignInAccount(); SocialProfile socialProfile = new SocialProfile(PROVIDER_GOOGLE, acct.getId(), acct.getPhotoUrl()==null?null:acct.getPhotoUrl().toString()); user = new User(acct.getEmail(), acct.getDisplayName(), socialProfile); loggedInMode = USER_LOGIN_GOOGLE; loginUser(user.getProvider() != null); } else { // Signed out, show unauthenticated UI. Log.d("G + logout"); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_OAUTH) { if (resultCode == Activity.RESULT_OK && data != null) { // Extract the server auth code and user email GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result.isSuccess() && result.getSignInAccount() != null) { AuthenticationInfo auth = new AuthenticationInfo(); auth.serverAuthCode = result.getSignInAccount().getServerAuthCode(); auth.accountEmail = result.getSignInAccount().getEmail(); Preferences.setAuthenticationInfo(getContext(), Provider.GDRIVE, auth); requestAccessToken(); return; } } handleError(); } }
private void handleSignInResult(GoogleSignInResult result) { if (BuildConfig.DEBUG) { Log.d(MCXApplication.LOG_TAG, "handleSignInResult:" + result.isSuccess() + " " + result.getStatus().getStatusCode() + result.getStatus().hasResolution()); } if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); User user = new User(); user.setProvider(PROVIDER_NAME); user.setProviderDisplayName("Google+"); user.setUserId(acct.getId()); user.setUserName(acct.getId()); user.setDisplayName(acct.getDisplayName()); user.setMail(acct.getEmail()); this.mUserHelper.setCurrentUser(user); if (this.mUserSessionCallback != null) { this.mUserSessionCallback.onLogin(); } } else { // Signed out, show unauthenticated UI. this.mUserSessionCallback.onLogout(); } }