Java Code Examples for com.google.firebase.auth.EmailAuthProvider#getCredential()
The following examples show how to use
com.google.firebase.auth.EmailAuthProvider#getCredential() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From snippets-android with Apache License 2.0 | 6 votes |
public void reauthenticate() { // [START reauthenticate] FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); // Get auth credentials from the user for re-authentication. The example below shows // email and password credentials but there are multiple possible providers, // such as GoogleAuthProvider or FacebookAuthProvider. AuthCredential credential = EmailAuthProvider .getCredential("[email protected]", "password1234"); // Prompt the user to re-provide their sign-in credentials user.reauthenticate(credential) .addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { Log.d(TAG, "User re-authenticated."); } }); // [END reauthenticate] }
Example 2
Source File: MainActivity.java From snippets-android with Apache License 2.0 | 5 votes |
public void getEmailCredentials() { String email = ""; String password = ""; // [START auth_email_cred] AuthCredential credential = EmailAuthProvider.getCredential(email, password); // [END auth_email_cred] }
Example 3
Source File: AnonymousAuthActivity.java From quickstart-android with Apache License 2.0 | 5 votes |
private void linkAccount() { // Make sure form is valid if (!validateLinkForm()) { return; } // Get email and password from form String email = mBinding.fieldEmail.getText().toString(); String password = mBinding.fieldPassword.getText().toString(); // Create EmailAuthCredential with email and password AuthCredential credential = EmailAuthProvider.getCredential(email, password); // Link the anonymous user to the email credential showProgressBar(); // [START link_credential] mAuth.getCurrentUser().linkWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { Log.d(TAG, "linkWithCredential:success"); FirebaseUser user = task.getResult().getUser(); updateUI(user); } else { Log.w(TAG, "linkWithCredential:failure", task.getException()); Toast.makeText(AnonymousAuthActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); updateUI(null); } // [START_EXCLUDE] hideProgressBar(); // [END_EXCLUDE] } }); // [END link_credential] }
Example 4
Source File: AnonymousAuthActivity.java From endpoints-samples with Apache License 2.0 | 5 votes |
private void linkAccount() { // Make sure form is valid if (!validateLinkForm()) { return; } // Get email and password from form String email = mEmailField.getText().toString(); String password = mPasswordField.getText().toString(); // Create EmailAuthCredential with email and password AuthCredential credential = EmailAuthProvider.getCredential(email, password); // Link the anonymous user to the email credential showProgressDialog(); // [START link_credential] mAuth.getCurrentUser().linkWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "linkWithCredential: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(AnonymousAuthActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } // [START_EXCLUDE] hideProgressDialog(); // [END_EXCLUDE] } }); // [END link_credential] }
Example 5
Source File: FirebaseAuthService.java From outlay with Apache License 2.0 | 5 votes |
@Override public Observable<User> linkCredentials(Credentials credentials) { AuthCredential emailCredentials = EmailAuthProvider.getCredential(credentials.getEmail(), credentials.getPassword()); return firebaseWrapper.linkAccount(emailCredentials) .map(authResult -> authResult.getUser()) .map(firebaseUser -> UserAdapter.fromFirebaseUser(firebaseUser)); }
Example 6
Source File: AuthOperationManager.java From FirebaseUI-Android with Apache License 2.0 | 5 votes |
public Task<AuthResult> createOrLinkUserWithEmailAndPassword(@NonNull FirebaseAuth auth, @NonNull FlowParameters flowParameters, @NonNull String email, @NonNull String password) { if (canUpgradeAnonymous(auth, flowParameters)) { AuthCredential credential = EmailAuthProvider.getCredential(email, password); return auth.getCurrentUser().linkWithCredential(credential); } else { return auth.createUserWithEmailAndPassword(email, password); } }
Example 7
Source File: ReferralActivity.java From snippets-android with Apache License 2.0 | 4 votes |
public void getCredential(String email, String password) { // [START ddl_referral_get_cred] AuthCredential credential = EmailAuthProvider.getCredential(email, password); // [END ddl_referral_get_cred] }