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(); } // ... } }); }
public void handleAccessToken(AccessToken token) { Utils.d("FB:Handle:AccessToken: " + token.getToken()); // showProgressDialog(); AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken()); mAuth.signInWithCredential(credential) .addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Utils.d("FB: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("FB:signInWithCredential" + task.getException().toString()); } // hideProgressDialog(); } }); }
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 handleTwitterSession(TwitterSession session) { Utils.d("Twitter:HandleSession:" + session); AuthCredential credential = TwitterAuthProvider.getCredential( session.getAuthToken().token, session.getAuthToken().secret); mAuth.signInWithCredential(credential) .addOnCompleteListener(activity, 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 Utils.d("signInWithCredential:success"); } else { // If sign in fails, display a message to the user. Utils.w("signInWithCredential:failure: " + task.getException()); } // ... } }); }
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 accessGithubLoginData(String accessToken, User githubUser){ String provider = "github"; AuthCredential credential = GithubAuthProvider.getCredential(accessToken); credential = provider.equalsIgnoreCase("github") ? GithubAuthProvider.getCredential( accessToken ) : credential; //user.saveProviderSP( LoginActivity.this, provider ); mFirebaseAuth.signInWithCredential(credential) .addOnCompleteListener(this, task -> { Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); saveUserGithubData("name", githubUser.name); saveUserGithubData("email", githubUser.email); saveUserGithubData("company", githubUser.company); saveUserGithubData("createdAt", String.valueOf(githubUser.created_at)); saveUserGithubData("bio", githubUser.bio); saveUserGithubData("location", githubUser.location); saveUserGithubData("numOfRepos", String.valueOf(githubUser.public_repos)); saveUserGithubData("followers", String.valueOf(githubUser.followers)); callMainActivity(); if (!task.isSuccessful()) { Log.w(TAG, "signInWithCredential", task.getException()); Toast.makeText(LoginActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } }); }
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 handleFacebookAccessToken(AccessToken token) { Log.d(TAG, "handleFacebookAccessToken:" + token); AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken()); 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"); updateUI(mAuth.getCurrentUser()); } else { // If sign in fails, display a message to the user. Log.w(TAG, "signInWithCredential:failure", task.getException()); Toast.makeText(LoginActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } } }); }
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 handleFacebookAccessToken(AccessToken token) { Log.d(TAG, "handleFacebookAccessToken:" + token); AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken()); 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 handleFacebookAccessToken(AccessToken token) { Log.d(TAG, "handleFacebookAccessToken:" + token); AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken()); fireBaseAuth.signInWithCredential(credential) .addOnCompleteListener(getActivity(), 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(getApplicationContext(), "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(); } } }); }
private void signInWithToken(String token) { // credential object from the token AuthCredential credential = GithubAuthProvider.getCredential(token); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { writeUserInfo(); } else { Log.d("github signInWithToken", "@3" + task.getException()); } } }); }
/** * 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 handleFacebookAccessToken(AccessToken token) { Log.d(TAG, "handleFacebookAccessToken:" + token); AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken()); 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 handleTwitterSession(TwitterSession session) { Log.d(TAG, "handleTwitterSession:" + session); AuthCredential credential = TwitterAuthProvider.getCredential( session.getAuthToken().token, session.getAuthToken().secret); 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 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 handleFacebookAccessToken(AccessToken token) { LogUtil.logDebug(TAG, "handleFacebookAccessToken:" + token); showProgress(); AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken()); 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) { 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); } } }); }