Search in sources :

Example 6 with Credential

use of com.google.android.gms.auth.api.credentials.Credential in project WordPress-Android by wordpress-mobile.

the class SignInActivity method onConnected.

@Override
public void onConnected(Bundle bundle) {
    AppLog.d(T.NUX, "Google API client connected");
    SignInFragment signInFragment = (SignInFragment) getSupportFragmentManager().findFragmentByTag(SignInFragment.TAG);
    // empty).
    if (signInFragment != null && signInFragment.canAutofillUsernameAndPassword()) {
        mSmartLockHelper.smartLockAutoFill(new Callback() {

            @Override
            public void onCredentialRetrieved(Credential credential) {
                SignInFragment signInFragment = (SignInFragment) getSupportFragmentManager().findFragmentByTag(SignInFragment.TAG);
                if (signInFragment != null) {
                    signInFragment.onCredentialRetrieved(credential);
                }
            }
        });
    }
}
Also used : Credential(com.google.android.gms.auth.api.credentials.Credential) Callback(org.wordpress.android.ui.accounts.SmartLockHelper.Callback)

Example 7 with Credential

use of com.google.android.gms.auth.api.credentials.Credential in project FirebaseUI-Android by firebase.

the class AuthUI method getDeleteTask.

private Task<Void> getDeleteTask(CredentialTaskApi credentialHelper) {
    FirebaseUser firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
    if (firebaseUser == null) {
        // If the current user is null, return a failed task immediately
        return Tasks.forException(new Exception("No currently signed in user."));
    }
    // Delete the Firebase user
    Task<Void> deleteUserTask = firebaseUser.delete();
    // Get all SmartLock credentials associated with the user
    List<Credential> credentials = SmartLockBase.credentialsFromFirebaseUser(firebaseUser);
    // For each Credential in the list, create a task to delete it.
    List<Task<?>> credentialTasks = new ArrayList<>();
    for (Credential credential : credentials) {
        credentialTasks.add(credentialHelper.delete(credential));
    }
    // Create a combined task that will succeed when all credential delete operations
    // have completed (even if they fail).
    final Task<Void> combinedCredentialTask = Tasks.whenAll(credentialTasks);
    // and return.
    return deleteUserTask.continueWithTask(new Continuation<Void, Task<Void>>() {

        @Override
        public Task<Void> then(@NonNull Task<Void> task) throws Exception {
            // Call getResult() to propagate failure by throwing an exception
            // if there was one.
            task.getResult(Exception.class);
            // Return the combined credential task
            return combinedCredentialTask;
        }
    });
}
Also used : Credential(com.google.android.gms.auth.api.credentials.Credential) Task(com.google.android.gms.tasks.Task) ArrayList(java.util.ArrayList) FirebaseUser(com.google.firebase.auth.FirebaseUser)

Aggregations

Credential (com.google.android.gms.auth.api.credentials.Credential)7 Activity (android.app.Activity)3 FragmentActivity (android.support.v4.app.FragmentActivity)3 Status (com.google.android.gms.common.api.Status)3 ArrayList (java.util.ArrayList)2 CredentialRequest (com.google.android.gms.auth.api.credentials.CredentialRequest)1 CredentialRequestResult (com.google.android.gms.auth.api.credentials.CredentialRequestResult)1 Task (com.google.android.gms.tasks.Task)1 FirebaseUser (com.google.firebase.auth.FirebaseUser)1 UserInfo (com.google.firebase.auth.UserInfo)1 Callback (org.wordpress.android.ui.accounts.SmartLockHelper.Callback)1