// [START auth_with_google] private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); // [START_EXCLUDE] showProgressDialog(); // [END_EXCLUDE] AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth .signInWithCredential(credential) .addOnCompleteListener( this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Log.w(TAG, "signInWithCredential", task.getException()); Toast.makeText( GoogleSignInActivity.this, "Authentication failed.", Toast.LENGTH_SHORT) .show(); } // [START_EXCLUDE] hideProgressDialog(); // [END_EXCLUDE] } }); }
// [START handleSignInResult] private void handleSignInResult(GoogleSignInResult result) { Log.d(TAG, "handleSignInResult:" + result.isSuccess()); if (result.isSuccess()) { GoogleSignInAccount acct = result.getSignInAccount(); Intent i = new Intent(getApplicationContext(), MainActivity.class); i.putExtra("email", acct.getEmail()); startActivity(i); finish(); } }
private void handleSignInResult(final GoogleSignInResult result) { Log.d(TAG, "handleSignInResult:" + result.isSuccess()); if (result.isSuccess()) { // Signed in successfully, show authenticated UI. final GoogleSignInAccount acct = result.getSignInAccount(); if (acct != null) { AccountUtils.setActiveAccount(getContext(), acct.getEmail()); doNext(); } } }
// [START handleSignInResult] private void handleSignInResult(GoogleSignInResult result) { Log.d(TAG, "handleSignInResult:" + result.isSuccess()); if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); String emailPref = acct.getEmail(); Log.d(TAG, " Handle signIn email of user" + emailPref); PrefUtils.setEmail(this, emailPref); // save Acct Name String namePref = acct.getDisplayName(); PrefUtils.setPersonKey(this, namePref); Uri mPhoto = acct.getPhotoUrl(); if (mPhoto != null) { // personPhotoUrl = acct.getPhotoUrl().toString(); personPhotoUrl = mPhoto.toString(); Log.e(TAG, "Profile Image" + personPhotoUrl); personPhotoUrl = personPhotoUrl.substring(0, personPhotoUrl.length() - 2) + PROFILE_PIC_SIZE; new LoadProfileImage().execute(personPhotoUrl); } else { Bitmap def = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); PrefUtils.setPhoto(this, def); Log.e(TAG, "Converted Launcher ICOn " + def); Toast.makeText(this, "Profile Loaded, Registering User", Toast.LENGTH_SHORT).show(); registerUser(); } } else { // Signed out, show unauthenticated UI. Toast.makeText( this, "Ensure you are connected to a Network to be able to Sign In", Toast.LENGTH_SHORT) .show(); // signOutUser(); RC_SIGN_IN++; // btEnter.setVisibility(View.GONE); // btnSignIn.setVisibility(View.VISIBLE); /*signOutUser(); Toast.makeText(this, "An Error Occured, Check your Network Connection Settings",Toast.LENGTH_SHORT).show(); btEnter.setVisibility(View.GONE); btnSignIn.setVisibility(View.VISIBLE);*/ // updateUI(false); } }
private void handleSignInResult(GoogleSignInResult result) { Log.d(TAG, "handleSignInResult:" + result.isSuccess()); if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); User user = new User(acct.getId(), acct.getEmail(), acct.getDisplayName()); AuthUtils.saveUser(this, user); } else { // Signed out, show unauthenticated UI. Toast.makeText(this, "Canceled", Toast.LENGTH_SHORT).show(); } }
// [START handleSignInResult] private void handleSignInResult(GoogleSignInResult result) { Log.d(TAG, "handleSignInResult:" + result.isSuccess()); if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); Log.d(TAG, "handleSignInResult:" + acct.getEmail()); emailID = acct.getEmail(); mStatusTextView.setText(getString(R.string.signed_in_fmt, acct.getDisplayName())); updateUI(true); } else { // Signed out, show unauthenticated UI. updateUI(false); } }
public void handleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) { GoogleSignInAccount account = result.getSignInAccount(); String userName = account.getDisplayName(); String userEmail = account.getEmail(); Uri userPhoto = account.getPhotoUrl(); Preferences.putString(Preferences.USER_NAME, userName); Preferences.putString(Preferences.USER_EMAIL, userEmail); Preferences.putString(Preferences.USER_PHOTO, userPhoto.toString()); Toast.makeText( getApplicationContext(), "Sign in account:" + account.getEmail(), Toast.LENGTH_SHORT) .show(); } else { Toast.makeText(getApplicationContext(), "Login Failed", Toast.LENGTH_SHORT).show(); } }
// [START handleSignInResult] private void handleSignInResult(GoogleSignInResult result) { Log.d("Test ", "handleSignInResult:" + result.isSuccess()); if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); String authCode = acct.getServerAuthCode(); Log.d("code", authCode); // mStatusTextView.setText(getString(R.string.signed_in_fmt, acct.getDisplayName())); // updateUI(true); // Stormpath.socialGoogleCodeAuth(SocialProvidersResponse.GOOGLE, new // SocialProviderConfiguration(getString(R.string.goog_app_id), // getString(R.string.goog_app_id)), new StormpathCallback<String>() { // @Override // public void onSuccess(String s) { // Log.d("THis worked", s); // } // // @Override // public void onFailure(StormpathError error) { // // } // }); Stormpath.socialLogin( SocialProvidersResponse.GOOGLE, null, authCode, new StormpathCallback<Void>() { @Override public void onSuccess(Void aVoid) { onLoginSuccessStormpath(); } @Override public void onFailure(StormpathError error) { Toast.makeText(getBaseContext(), "Log in failed", Toast.LENGTH_SHORT).show(); } }); } else { // Signed out, show unauthenticated UI. // updateUI(false); } }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth .signInWithCredential(credential) .addOnCompleteListener( this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (!task.isSuccessful()) { Toast.makeText( SignInActivity.this, R.string.erro_google_sign_in, Toast.LENGTH_SHORT) .show(); } } }); }