Java 类com.google.firebase.auth.AuthResult 实例源码

项目:Howl    文件:RegisterInteractor.java   
@Override
public void performFirebaseRegistration(Activity activity, final String email, String password) {
    FirebaseAuth.getInstance()
            .createUserWithEmailAndPassword(email, password)
            .addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.e(TAG, "performFirebaseRegistration: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()) {
                        mOnRegistrationListener.onFailure(task.getException().getMessage());
                    } else {
                        // Add the user to users table.
                        /*DatabaseReference database= FirebaseDatabase.getInstance().getReference();
                        User user = new User(task.getResult().getUser().getUid(), email);
                        database.child("users").push().setValue(user);*/

                        mOnRegistrationListener.onSuccess(task.getResult().getUser());
                    }
                }
            });
}
项目:BuddiesGo    文件:SignInActivity.java   
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();
                    }
                }
            });
}
项目:digits-migration-helper-android    文件:AuthMigratorTest.java   
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    when(mockStorageHelpers.getApiKeyFromManifest(any(Context.class), eq(StorageHelpers
            .DIGITS_CONSUMER_KEY_KEY))).thenReturn(DIGITS_CONSUMER_KEY);
    when(mockStorageHelpers.getApiKeyFromManifest(any(Context.class), eq(StorageHelpers
            .DIGITS_CONSUMER_SECRET_KEY))).thenReturn(DIGITS_CONSUMER_SECRET);
    when(mockStorageHelpers.getApiKeyFromManifest(any(Context.class), eq(StorageHelpers
            .FABRIC_API_KEY_KEY))).thenReturn(FABRIC_API_KEY);
    authResult = new AuthResult() {
        @Override
        public FirebaseUser getUser() {
            return mockFirebaseUser;
        }

        @Override
        public AdditionalUserInfo getAdditionalUserInfo() {
            return null;
        }
    };

    authResultTask = Tasks.forResult(authResult);
}
项目:Charities    文件:ListWishesActivity.java   
private void signIn(String email, String password) {
    Log.d(TAG, "signIn:" + email);
    mAuth.signInWithEmailAndPassword(email, password)
            .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, "signInWithEmail:success");
                        FirebaseUser user = mAuth.getCurrentUser();

                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w(TAG, "signInWithEmail:failure", task.getException());
                    }
                }
            });
}
项目:snippets-android    文件:MainActivity.java   
private void authWithGithub() {
    FirebaseAuth mAuth = FirebaseAuth.getInstance();

    // [START auth_with_github]
    String token = "<GITHUB-ACCESS-TOKEN>";
    AuthCredential credential = GithubAuthProvider.getCredential(token);
    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();
                    }

                    // ...
                }
            });
    // [END auth_with_github]
}
项目:wirtualnaApteczka    文件:LogInOnCompleteListener.java   
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
    if (task.isSuccessful()) {
        FirebaseAuth firebaseAuth = SessionManager.getFirebaseAuth();
        FirebaseUser currentUser = SessionManager.getFirebaseUser();

        boolean isEmailVerified = currentUser.isEmailVerified();
        // TODO zmienić z powrotem
        if (true) {
            updateLoginConfigInSharedPrefs();

            SessionManager.initializeCurrentUserFirebaseListeners();
            SessionManager.initializeFamilyMembersFirebaseListener();

            Intent intent = new Intent(context, MainActivity.class);
            context.startActivity(intent);
        } else {
            firebaseAuth.signOut();
            Toast.makeText(context, R.string.email_not_verified, Toast.LENGTH_LONG).show();
        }
    } else {
        logger.logWarn("Sign In Failure: " + task.getException());
        Toast.makeText(context, R.string.invalid_email_or_password, Toast.LENGTH_LONG).show();
    }
}
项目:Quadro    文件:AuthActivity.java   
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();
                    }
                    // ...
                }
            });
}
项目:GodotFireBase    文件:TwitterSignIn.java   
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());
            }

            // ...
        }
    });
}
项目:GodotFireBase    文件:EmailAndPassword.java   
public void createAccount(final String email, final String password) {
    Utils.d("E&P:CreateAccount:" + email);

    mAuth.createUserWithEmailAndPassword(email, password)
    .addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            Utils.d("E&P:CreateUserWithEmail: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.d("E&P:CreateAccount:Error");
            }
        }
    });
}
项目:instagram_clone    文件:AccountActivity.java   
private void signInWithEmail(final String email, final String password) {
    mAuth.signInWithEmailAndPassword(email, password)
            .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, "signInWithEmail:success");
                        FirebaseUser user = mAuth.getCurrentUser();
                        Toast.makeText(AccountActivity.this, "Authentication successful",
                                Toast.LENGTH_SHORT).show();
                        Intent intent = new Intent(AccountActivity.this, HomeActivity.class);
                        startActivity(intent);
                        finish();
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w(TAG, "signInWithEmail:failure. Signing Up for new account instead.", task.getException());
                        Toast.makeText(AccountActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
}
项目:social-app-android    文件:LoginActivity.java   
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);
                    }
                }
            });
}
项目:furry-sniffle    文件:CreateProfileTest.java   
@Before
public void initValideString(){
    displayName = "Musa";
    fullName = "MusaRikhotso";

    FirebaseApp.initializeApp(rule.getActivity());
    mAuth = FirebaseAuth.getInstance();

    mAuth.signInWithEmailAndPassword("testgmail.com", "password")
            .addOnCompleteListener(rule.getActivity(), 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
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w("login activity", "signInWithEmail:failure", task.getException());

                    }
                }
            });
}
项目:shared-firebase-preferences    文件:TestActivity.java   
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_test);

    FirebaseApp.initializeApp(this);
    FirebaseAuth.getInstance().addAuthStateListener(this);

    FirebaseAuth.getInstance().signInAnonymously()
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInAnonymously: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, "signInAnonymously", task.getException());
                        Toast.makeText(TestActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
}
项目:VR-One    文件:SignInActivity.java   
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();
                    }
                }
            });
}
项目:Viajes    文件:LoginPresenter.java   
@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();
                    }
                }
            });
}
项目:Profiler    文件:FirebaseAuthService.java   
@Override
public Completable createAccount(final Credentials cred) {
    return Completable.create(new CompletableOnSubscribe() {
        @Override
        public void subscribe(final CompletableEmitter e) throws Exception {
            if (auth == null) {
                auth = FirebaseAuth.getInstance();
            }

            auth.createUserWithEmailAndPassword(cred.getEmail(), cred.getPassword())
                    .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task) {
                            if (task.isSuccessful()) {
                                e.onComplete();
                            } else {
                                e.onError(task.getException());
                            }
                        }
                    });

        }
    });
}
项目:Profiler    文件:FirebaseAuthService.java   
@Override
public Completable attemptLogin(final Credentials cred) {
    return Completable.create(new CompletableOnSubscribe() {
        @Override
        public void subscribe(final CompletableEmitter e) throws Exception {
            if (auth == null) {
                auth = FirebaseAuth.getInstance();
            }

            auth.signInWithEmailAndPassword(cred.getEmail(), cred.getPassword())
                    .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task) {
                            if (task.isSuccessful()) {
                                e.onComplete();
                            } else {
                                e.onError(task.getException());
                            }
                        }
                    });
        }
    });
}
项目:BookED    文件:Authentication.java   
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();
                    }
                    // ...
                }
            });
}
项目:CollegeDoc    文件:MainActivity.java   
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();
                    }
                }
            });
}
项目:friendlypix-android    文件:WelcomeActivity.java   
@Override
public void onClick(View v) {
    int id = v.getId();
    switch (id) {
        case R.id.explore_button:
            mAuth.signInAnonymously().addOnSuccessListener(new OnSuccessListener<AuthResult>() {
                @Override
                public void onSuccess(AuthResult authResult) {
                    Intent feedsIntent = new Intent(WelcomeActivity.this, FeedsActivity.class);
                    startActivity(feedsIntent);
                }
            }).addOnFailureListener( new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Toast.makeText(WelcomeActivity.this, "Unable to sign in anonymously.",
                            Toast.LENGTH_SHORT).show();
                        Log.e(TAG, e.getMessage());
                }
            });
            break;
        case R.id.sign_in_button:
            Intent signInIntent = new Intent(this, ProfileActivity.class);
            startActivity(signInIntent);
            break;
    }
}
项目:Android-MVP-vs-MVVM-Samples    文件:AuthModuleImpl.java   
@Override
public final void signIn(final String email, final String password, final Callback callback) {
    signInCallback = callback;

    // TODO: 23-Feb-17 validate email, pass;

    firebaseAuthManager.signInWithEmailAndPassword(email, password, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            final Exception exception = task.getException();
            printStackTrace(exception);
            if (signInCallback != null) {
                signInCallback.onComplete(task.isSuccessful(), exception != null ? exception.getMessage() : "");
            }
        }
    });
}
项目:PimPam    文件:LoginInteractorImpl.java   
@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();
                    }

                }
            });
}
项目:ReminderPrj    文件:startPage.java   
public void signIn(View view){
    String email = emailEdt.getText().toString();
    String password = passwordEdt.getText().toString();
    mAuth.signInWithEmailAndPassword(email, password)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithEmail: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, "signInWithEmail:failed", task.getException());
                        Toast.makeText(startPage.this, "Authentication Failed",
                                Toast.LENGTH_SHORT).show();
                    }

                    // ...
                }
            });
}
项目:android-paypal-example    文件:LoginActivity.java   
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();
                        }

                    }
                });
    }
项目:Programmers    文件:UserRemoteDataSource.java   
@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);
                }
            });
}
项目:CowBit    文件:FirebaseHelper.java   
public void signIn(String email, String password) {
    mAuth.signInWithEmailAndPassword(email, password)
            .addOnCompleteListener(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, "signInWithEmail:success");
                        mCurrentUser = mAuth.getCurrentUser();

                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w(TAG, "signInWithEmail:failure", task.getException());
                        mCurrentUser = null;
                    }
                }
            });
}
项目:Expert-Android-Programming    文件:SignInBaseActivity.java   
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();
                }
            });
}
项目:PiPle    文件:LoginActivity.java   
/**
 * Method signIn
 *
 * Allows a registered user to sign in.
 *
 * @param email mail address used for his account
 * @param password password to access his account
 */
private void signIn(String email, String password)
{
    mFirebaseAuth.signInWithEmailAndPassword(email, password)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        Log.d(TAG, "signInWithEmail: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, "signInWithEmail", task.getException());
                            Toast.makeText(LoginActivity.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                        } else {
                            startActivity(new Intent(LoginActivity.this, HomeActivity.class));
                            finish();
                        }
                    }
                });

}
项目:iSPY    文件:TrackerService.java   
private void authenticate(String email, String password) {

        final FirebaseAuth mAuth = FirebaseAuth.getInstance();
        mAuth.signInWithEmailAndPassword(email, password)
                .addOnCompleteListener(new OnCompleteListener<AuthResult>(){
                    @Override
                    public void onComplete(Task<AuthResult> task) {

                        if (task.isSuccessful()) {
                            fetchRemoteConfig();
                            loadPreviousStatuses();
                        } else {
                            Log.i("not sign", "authenticate: " + task.getException().getMessage().toString());

                            Toast.makeText(TrackerService.this, R.string.auth_failed,
                                    Toast.LENGTH_SHORT).show();
                            stopSelf();
                        }
                    }
                });
    }
项目:social-app-android    文件:LoginActivity.java   
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);
                    }
                }
            });
}
项目:NITKart    文件:newUser.java   
private void createAccount() {
    progressBar.setVisibility(View.VISIBLE);

    mAuth.createUserWithEmailAndPassword(email, password)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
                    isRegistrationClicked = true;
                    // 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()) {
                        Toast.makeText(newUser.this, R.string.auth_failed, Toast.LENGTH_SHORT).show();
                        setViews(true);
                        isRegistrationClicked = false;
                        progressBar.setVisibility(View.GONE);
                    }
                    // ...
                }
            });
}
项目:WaJeun    文件:MainActivity.java   
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();
                    }
                    // ...
                }
            });
}
项目:Opal-Chat-AnalyticsDashboard    文件:AuthSourceImpl.java   
@Override
public void attemptLogin(Credentials credentials, final AuthCallback<Void> authCallback) {
    mFirebaseAuth.signInWithEmailAndPassword(
            credentials.getEmail(),
            credentials.getPassword()
    ).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            if (task.isSuccessful()) {
                authCallback.onSuccess(null);
            } else {
                authCallback.onFailure(task.getException());
            }

        }
    });
}
项目:Ae4Team    文件:ChangePhoneNumberActivity.java   
private void link() {
    if (phoneNumberCheck() == true) {
        mAuth.getCurrentUser().linkWithCredential(credent)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            Log.d(TAG, "linkWithCredential:success");
                            Toast.makeText(ChangePhoneNumberActivity.this, "변경되었습니다", Toast.LENGTH_SHORT).show();
                            IntentBack();
                        } else {
                            Log.w(TAG, "linkWithCredential:failure", task.getException());
                            Toast.makeText(ChangePhoneNumberActivity.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                        }
                        // ...
                    }
                });
    } else {
        Toast.makeText(ChangePhoneNumberActivity.this, "이미 등록되어있는 번호입니다.", Toast.LENGTH_SHORT).show();
    }
}
项目:FirebasePost    文件:RegisterActivity.java   
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();
                    }

                    // ...
                }
            });
}
项目:CineReminDay    文件:CRDAuthActivity.java   
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();
                    }
                }
            });
}
项目:foodie    文件:MainActivity.java   
public void createAccount(String email, String password){
    mAuth.createUserWithEmailAndPassword(email, password)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "createUserWithEmail: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()) {
                        Toast.makeText(MainActivity.this, R.string.auth_failed,
                                Toast.LENGTH_SHORT).show();
                    }else{
                        Toast.makeText(MainActivity.this, "success",
                                Toast.LENGTH_SHORT).show();
                    }

                    // ...
                }
            });
}
项目:social-journal    文件:LoginCallback.java   
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
    String tagText;
    if (linkToExisting) {
        tagText = "linkWithCredential";
    } else {
        tagText = "signInWithCredential";
    }

    Log.d(TAG, tagText + ":onComplete:" + task.isSuccessful());

    if (task.isSuccessful()) {
        Log.d(TAG, tagText + ":success");
        useSocialNetwork(socialNetworkKey);
    } else {
        Log.d(TAG, tagText + ":failure");
    }
}
项目:androidadvanced    文件:LoginRepositoryImpl.java   
@Override
public void signUp(final String email, final String password) {
    FirebaseAuth.getInstance().createUserWithEmailAndPassword(email, password)
            .addOnSuccessListener(new OnSuccessListener<AuthResult>() {
                @Override
                public void onSuccess(AuthResult authResult) {
                    post(LoginEvent.onSignUpSuccess);
                    signIn(email, password);
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    post(LoginEvent.onSignUpError, e.getMessage());
                }
            });

}