@Override public Completable loginWithGoogle(final Activity activity) { return Single.create((SingleOnSubscribe<AuthCredential>) e -> { googleClient = new GoogleApiClient.Builder(activity) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleClient); activity.startActivityForResult(signInIntent, RC_GOOGLE_SIGN_IN); googleSignInCompleteListener = result -> { if(result.isSuccess()) { AuthCredential credential = GoogleAuthProvider.getCredential(result.getSignInAccount().getIdToken(), null); e.onSuccess(credential); } else { e.onError(new Exception(result.getStatus().toString())); } }; }).flatMapCompletable(authCredential -> signInWithCredential(activity, authCredential)); }
private void handleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) { Log.d(TAG, "googleSignIn:SUCCESS"); handleSignInSuccess(result.getSignInAccount()); } else { Log.d(TAG, "googleSignIn:FAILURE:" + result.getStatus()); Toast.makeText(getActivity(), R.string.network_error, Toast.LENGTH_LONG).show(); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); mCallbackManager.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUESTCODE_SIGN_IN_GOOGLE) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result.isSuccess()) { // Google Sign In was successful, authenticate with Firebase GoogleSignInAccount account = result.getSignInAccount(); firebaseAuthWithGoogle(account); } else { mPrgrsbrMain.setVisibility(View.GONE); Snackbar.make(mCrdntrlyot, "Google authentication failed.", Snackbar.LENGTH_LONG).show(); } } }
@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 // ... } } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_SIGN_IN) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); Log.i(TAG, "onActivityResult: "+result); Log.i(TAG, "onActivityResult: "+result.getStatus()); Log.i(TAG, "onActivityResult: "+result.getSignInAccount()); Log.i(TAG, "onActivityResult: "+result.isSuccess()); Log.i(TAG, "onActivityResult: "+result.toString()); 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] Toast.makeText(LoginActivity.this, "Error", Toast.LENGTH_SHORT).show(); Log.i(TAG, "onActivityResult: "+result.getStatus().getStatusMessage()); // [END_EXCLUDE] } hideProgress(); } } private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
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()); } } }); } }
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()); } }
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()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); mListener.onGoogleAuthSignIn(parseToGoogleUser(acct)); } else { mListener.onGoogleAuthSignInFailed(); } } }
Log.d("Reached", "1"); GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result.isSuccess()) {
@Override protected void onActivityResult(int request, int response, Intent data) { super.onActivityResult(request, response, data); if (request == REQUEST_SIGN_IN) { if (BuildConfig.DEBUG) { Log.d(TAG, "onActivityResult with requestCode == REQUEST_SIGN_IN, responseCode=" + response + ", intent=" + data); } GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); GoogleSignInAccount signInAccount = result.getSignInAccount(); if (result.isSuccess() && signInAccount != null) { onConnected(signInAccount); } else { GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); final int errorCode = googleApiAvailability.isGooglePlayServicesAvailable(this); Dialog dialog = googleApiAvailability.getErrorDialog(this, errorCode, REQUEST_SIGN_IN); if (dialog != null) { dialog.show(); } } } if (request == REQUEST_GAME && response == RESULT_OK) { WinDialogFragment winDialogFragment = WinDialogFragment.createInstance(data); winDialogFragment.show(getFragmentManager(), "win"); } }
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RC_SIGN_IN) { final GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result.isSuccess()) { AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(Void... params) { String token = null; try { token = GoogleAuthUtil.getToken(mContext, result.getSignInAccount().getAccount(), SCOPES); } catch (IOException | GoogleAuthException e) { e.printStackTrace(); } return token; } @Override protected void onPostExecute(String token) { GoogleSignInAccount acct = result.getSignInAccount(); mListener.onGoogleAuthSignIn(token, acct.getId()); } }; task.execute(); } else { mListener.onGoogleAuthSignInFailed(result.getStatus().getStatusMessage()); } } }
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"); } }
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(); } }
@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(); } }