private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGooogle:" + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mFirebaseAuth.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(SignInActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } else { startActivity(new Intent(SignInActivity.this, MainActivity.class)); finish(); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mFirebaseAuth.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(SignInActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } else { startActivity(new Intent(SignInActivity.this, MainActivity.class)); finish(); } } }); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_SIGNIN_GOOGLE) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result.isSuccess()) { GoogleSignInAccount account = result.getSignInAccount(); AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null); auth.signInWithCredential(credential) .addOnCompleteListener(this, this); } else onFailure(result.getStatus().toString()); } else callbackManager.onActivityResult(requestCode, resultCode, data); }
private void firebaseAuthWithGoogle(GoogleSignInAccount account) { Log.d(TAG, "firebaseAuthWithGoogle:" + account.getId()); showProgressDialog(); AuthCredential credential = GoogleAuthProvider.getCredential(account.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()); hideProgressDialog(); // 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(AuthActivity.this, R.string.auth_failed, Toast.LENGTH_SHORT).show(); } // ... } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Utils.d("Google:FirebaseAuthWithGoogle:" + acct.getId()); // FireBase.showProgressDialog(); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Utils.d( "Google: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()) { Utils.w("Google:SignInWithCredential:" + task.getException()); } // FireBase.hideProgressDialog(); } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); 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(SignInActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } } }); }
@Override public void firebaseAuthWithGoogle(final GoogleSignInAccount account) { final AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(mContext, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { mLoginView.dismissProgress(); if (!task.isSuccessful()) { mLoginView.showErrorMessage("Error In Create User"); } else { FirebaseAuth.getInstance().getCurrentUser().linkWithCredential(credential); String uid = task.getResult().getUser().getUid(); String name = account.getDisplayName(); String email = account.getEmail(); String imageProfileUrl = getHighQualityImage(account.getPhotoUrl()); createUserInFirebaseHelper(uid, new User(name, email, imageProfileUrl)); mLoginView.showMain(); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); 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(Authentication.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } // ... } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGooogle:" + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); showProgressDialog(getString(R.string.profile_progress_message)); mAuth.signInWithCredential(credential) .addOnSuccessListener(this, new OnSuccessListener<AuthResult>() { @Override public void onSuccess(AuthResult result) { handleFirebaseAuthResult(result); } }) .addOnFailureListener(this, new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { FirebaseCrash.logcat(Log.ERROR, TAG, "auth:onFailure:" + e.getMessage()); handleFirebaseAuthResult(null); } }); }
public static AuthCredential getCredential(final JSONObject credential) throws Exception { final String providerId = credential.getString("provider"); AuthCredential authCredential; if (providerId.equals(EmailAuthProvider.PROVIDER_ID)) { authCredential = getEmailAuthCredential(credential); } else if (providerId.equals(FacebookAuthProvider.PROVIDER_ID)) { authCredential = getFacebookAuthCredential(credential); } else if (providerId.equals(GithubAuthProvider.PROVIDER_ID)) { authCredential = getGithubAuthCredential(credential); } else if (providerId.equals(GoogleAuthProvider.PROVIDER_ID)) { authCredential = getGoogleAuthCredential(credential); } else if (providerId.equals(TwitterAuthProvider.PROVIDER_ID)) { authCredential = getTwitterAuthCredential(credential); } else { throw new Exception("Unknown provider ID: " + providerId); } return authCredential; }
@Override public void firebaseAuthWithGoogle(GoogleSignInAccount acct,final OnLoginFinishedListener listener) { AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { // 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()) { listener.onLoginGoogleFail(); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mFirebaseAuth.signInWithCredential(credential) .addOnCompleteListener(this, task -> { if (!task.isSuccessful()) { Toast.makeText(AllBooks.this, R.string.auth_error, Toast.LENGTH_SHORT).show(); signInSuccess = null; } else { Toast.makeText(AllBooks.this, R.string.sign_in_ok, Toast.LENGTH_SHORT).show(); if (signInSignOut != null) { if (mFirebaseAuth.getCurrentUser() != null) { signInSignOut.setTitle(R.string.sign_out); } else { signInSignOut.setTitle(R.string.sign_in); } } if (signInSuccess != null) { signInSuccess.run(); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); 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(MainActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } // ... } }); }
private void logInToFirebaseWithGoogleSignIn(GoogleSignInAccount googleSignInAccount) { Log.v(CRDAuthActivity.class.getName(), "logInToFirebaseWithGoogleSignIn() called with: " + "googleSignInAccount = [" + googleSignInAccount + "]"); // TODO VOLKO MAKE USER WAIT AuthCredential credential = GoogleAuthProvider.getCredential(googleSignInAccount.getIdToken(), null); FirebaseAuth.getInstance() .signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.v(CRDAuthActivity.class.getName(), "logInToFirebaseWithGoogleSignIn.onComplete() called with: " + "isSuccessful = [" + task.isSuccessful() + "]"); // TODO VOLKO MAKE USER DE-WAIT // 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()) { onFirebaseConnectionFailed(); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); showProgressDialog(); 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()) { // Sign in success, update UI with the signed-in user's information Log.d(TAG, "signInWithCredential:success"); startActivity(new Intent(LoginActivity.this, FindConnectionActivity.class)); finish(); } else { // If sign in fails, display a message to the user. Log.w(TAG, "signInWithCredential:failure", task.getException()); Toast.makeText(LoginActivity.this, TAG + ": " + "Authentication failed.", Toast.LENGTH_SHORT).show(); } hideProgressDialog(); } }); }
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()) { getUserInfo(); } else { Log.w(TAG, "signInWithCredential:failure", task.getException()); Toast.makeText(LoginActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } } }); }
/** * Method firebaseAuthWithGoogle * * Authenticates in Firebase through a Google Account. */ private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mFirebaseAuth.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(LoginActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } else { startActivity(new Intent(LoginActivity.this, HomeActivity.class)); finish(); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); progress = ProgressDialog.show(this, "Login...", "", true); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, task -> { if (task.isSuccessful()) { currentUser = mAuth.getCurrentUser(); Log.e(TAG, "signInWithCredential:success"); loadRooms(); updateUI(currentUser); } else { Log.e(TAG, "signInWithCredential:failure", task.getException()); Toast.makeText(LoginActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); updateUI(null); } }); }
@Override public Completable signInWithGoogle(final String token) { return Completable.create(e -> { final AuthCredential credential = GoogleAuthProvider.getCredential(token, null); auth.signInWithCredential(credential).addOnCompleteListener(task -> { if (!e.isDisposed()) { if (task.isSuccessful()) { e.onComplete(); } else { if (task.getException() != null) { e.onError(task.getException()); } else { e.onError(new UnknownError()); } } } }); }); }
/** * Authenticate Google user with Firebase * @param acct Google account */ private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(mContext, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { // Sign in success, update UI with the signed-in user's information Log.d(TAG, "signInWithCredential:success"); onSuccess(); } else { // If sign in fails, display a message to the user. Log.w(TAG, "signInWithCredential:failure", task.getException()); onFailed(); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { MyLg.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()+" "+acct.getPhotoUrl()); showProgressDialog(); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { MyLg.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()) { MyLg.w(TAG, "signInWithCredential"); Toas.show(context, "Authentication failed."); } hideProgressDialog(); } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { FirebaseAuth.getInstance().signInWithCredential(GoogleAuthProvider.getCredential(acct.getIdToken(), null)) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { startSideBarActivity(); } else { // To always present the user the same login failure message and process we handle a // firebase failure by simply prompting him to redo the whole authentication process. loginFailed(); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); auth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d("HERE", "signInWithCredential:onComplete:" + task.isSuccessful()); Intent intent = new Intent(getApplicationContext(), HomeActivity.class); startActivity(intent); finish(); // 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("HERE", "signInWithCredential", task.getException()); Toast.makeText(LoginActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); showProgressDialog(); 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 (!task.isSuccessful()) { Log.w(TAG, "signInWithCredential", task.getException()); Toast.makeText(SaveReports.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } hideProgressDialog(); } }); }
@Override public void firebaseAuthWithGoogle(GoogleSignInAccount account, final Callbacks.IResultCallback<Usuario> callback) { showLog("firebaseAuthWithGoogle: " + account.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null); FirebaseAuth.getInstance() .signInWithCredential(credential) .addOnFailureListener( reportError(callback)) .addOnSuccessListener(new OnSuccessListener<AuthResult>() { @Override public void onSuccess(AuthResult authResult) { FirebaseUser user = authResult.getUser(); loginFlow( user, callback); } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); 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()) { hideProgressDialog(); // Sign in success, update UI with the signed-in user's information Log.d(TAG, "signInWithCredential:success"); // FirebaseUser user = mAuth.getCurrentUser(); startApp(); } else { hideProgressDialog(); // If sign in fails, display a message to the user. Log.w(TAG, "signInWithCredential:failure", task.getException()); Toast.makeText(BaseAuthActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } // ... } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { LogUtil.logDebug(TAG, "firebaseAuthWithGoogle:" + acct.getId()); showProgress(); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { LogUtil.logDebug(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()) { handleAuthError(task); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); 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()) { // Sign in success, update UI with the signed-in user's information Log.d(TAG, "signInWithCredential:success"); FirebaseUser user = mAuth.getCurrentUser(); printLog(TAG, "current user :" + user.getDisplayName()); updateUser(user); updateUi(); } else { // If sign in fails, display a message to the user. Log.w(TAG, "signInWithCredential:failure", task.getException()); Toast.makeText(RegisterActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } // ... } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()+acct.getIdToken()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mFirebaseAuth.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(SignInActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } else { startActivity(new Intent(SignInActivity.this, MainActivity.class)); finish(); } } }); }
private void firebaseAuthWithGoogle(final GoogleSignInAccount acct) { Log.d("firebaseAuthWithGoogle", "Account ID " + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); firebaseAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { // Sign in success, update UI with the signed-in user's information Log.d("signInWithCredential", "Success"); FirebaseUser user = firebaseAuth.getCurrentUser(); user.updateEmail(acct.getEmail()); } else { // If sign in fails, display a message to the user. Log.w("signInWithCredential", "Failed", task.getException()); Toast.makeText(ActivitySelectAuthentication.this, "Firebase authentication failed.", Toast.LENGTH_SHORT).show(); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); avi.show(); 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 (task.isSuccessful()) { // User is signed in, getAccount of Members GetAccount getAccount = new GetAccount(mContext); getAccount.execute(); Toast.makeText(Authenticate.this, R.string.auth_success, Toast.LENGTH_SHORT).show(); } else { Log.d(TAG, "signInWithCredential", task.getException()); Toast.makeText(Authenticate.this, R.string.auth_failed, Toast.LENGTH_SHORT).show(); } avi.hide(); } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); auth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (!task.isSuccessful()) { Toast.makeText(LoginTempActivity.this, R.string.error_auth, Toast.LENGTH_SHORT).show(); showMainScreen(); }else{ FirebaseUser firebaseUser = task.getResult().getUser(); User user = new User(); user.setDisplayName(firebaseUser.getDisplayName()); user.setEmail(firebaseUser.getEmail()); user.setId(firebaseUser.getUid()); if(firebaseUser.getPhotoUrl() != null){ user.setProfileImageURL(firebaseUser.getPhotoUrl().toString()); } user.setToken(user.getToken()); repository.saveUser(user); showMainScreen(); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); auth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (!task.isSuccessful()) { Toast.makeText(LoginActivity.this, R.string.error_auth, Toast.LENGTH_SHORT).show(); showMainScreen(); }else{ FirebaseUser firebaseUser = task.getResult().getUser(); User user = new User(); user.setDisplayName(firebaseUser.getDisplayName()); user.setEmail(firebaseUser.getEmail()); user.setId(firebaseUser.getUid()); if(firebaseUser.getPhotoUrl() != null){ user.setProfileImageURL(firebaseUser.getPhotoUrl().toString()); } user.setToken(user.getToken()); repository.saveUser(user); showMainScreen(); } } }); }
/** * Firebase Auth With Google * * @param account GoogleSignInAccount */ private void firebaseAuthWithGoogle(GoogleSignInAccount account) { Log.d(TAG, "FirebaseAuthWithGoogle:" + account.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null); mFirebaseAuth.signInWithCredential(credential) .addOnCompleteListener(getActivity(), task -> { ProgressDialogHelper.dismiss(); Log.d(TAG, "[LOGIN_ACTIVITY] 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, String.format("[LOGIN_ACTIVITY] SignInWithCredential:%s", task.getException())); Toast.makeText(getActivity(), "Authentication Failed", Toast.LENGTH_LONG).show(); } else { createUserIfNotExists(); } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); showProgressDialog(); 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(SignInActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } hideProgressDialog(); } }); }
@Override public Observable<Authentication> loginWithGoogle(final String idToken) { return Observable.create(new Observable.OnSubscribe<Authentication>() { @Override public void call(final Subscriber<? super Authentication> subscriber) { AuthCredential credential = GoogleAuthProvider.getCredential(idToken, null); firebaseAuth.signInWithCredential(credential) .addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { FirebaseUser firebaseUser = task.getResult().getUser(); subscriber.onNext(authenticationFrom(firebaseUser)); } else { subscriber.onNext(new Authentication(task.getException())); } subscriber.onCompleted(); } }); } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, getString(R.string.firebase_google) + acct.getId()); showProgressDialog(); 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, getString(R.string.signInWithCredential_complete) + 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, getString(R.string.signInWithCredential), task.getException()); Toast.makeText(AuthActivity.this, getString(R.string.authentication_failed), Toast.LENGTH_SHORT).show(); } // [START_EXCLUDE] hideProgressDialog(); // [END_EXCLUDE] } }); }
@Override public void logInWithFirebase(GoogleSignInAccount account) { Log.d(TAG, "firebaseAuthWithGoogle:" + account.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null); mFirebaseAuth.signInWithCredential(credential) .addOnCompleteListener((Activity) mContext, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); if (!task.isSuccessful()) { Log.w(TAG, "signInWithCredential", task.getException()); mView.showFirebaseAuthenticationFailedMessage(); } else { mView.startChatListActivity(); } } }); }