Search in sources :

Example 1 with CredentialTaskApi

use of com.firebase.ui.auth.util.CredentialTaskApi in project FirebaseUI-Android by firebase.

the class AuthUI method delete.

/**
     * Delete the use from FirebaseAuth and delete any associated credentials from the Credentials
     * API. Returns a {@code Task} that succeeds if the Firebase Auth user deletion succeeds and
     * fails if the Firebase Auth deletion fails. Credentials deletion failures are handled
     * silently.
     *
     * @param activity the calling {@link Activity}.
     * @deprecated use {@link #delete(FragmentActivity)} instead
     */
@Deprecated
public Task<Void> delete(@NonNull Activity activity) {
    // Initialize SmartLock helper
    GoogleApiClientTaskHelper gacHelper = GoogleApiClientTaskHelper.getInstance(activity);
    gacHelper.getBuilder().addApi(Auth.CREDENTIALS_API);
    CredentialTaskApi credentialHelper = CredentialsApiHelper.getInstance(gacHelper);
    return getDeleteTask(credentialHelper);
}
Also used : GoogleApiClientTaskHelper(com.firebase.ui.auth.util.GoogleApiClientTaskHelper) CredentialTaskApi(com.firebase.ui.auth.util.CredentialTaskApi)

Example 2 with CredentialTaskApi

use of com.firebase.ui.auth.util.CredentialTaskApi in project FirebaseUI-Android by firebase.

the class AuthUI method signOut.

/**
     * Signs the current user out, if one is signed in.
     *
     * @param activity The activity requesting the user be signed out.
     * @return a task which, upon completion, signals that the user has been signed out ({@code
     * result.isSuccess()}, or that the sign-out attempt failed unexpectedly ({@code
     * !result.isSuccess()}).
     * @deprecated use {@link #signOut(FragmentActivity)} instead
     */
@Deprecated
public Task<Void> signOut(@NonNull Activity activity) {
    // Get helper for Google Sign In and Credentials API
    GoogleApiClientTaskHelper taskHelper = GoogleApiClientTaskHelper.getInstance(activity);
    taskHelper.getBuilder().addApi(Auth.CREDENTIALS_API).addApi(Auth.GOOGLE_SIGN_IN_API, GoogleSignInOptions.DEFAULT_SIGN_IN);
    // Get Credentials Helper
    CredentialTaskApi credentialsHelper = CredentialsApiHelper.getInstance(taskHelper);
    // Firebase Sign out
    mAuth.signOut();
    // Disable credentials auto sign-in
    Task<Status> disableCredentialsTask = credentialsHelper.disableAutoSignIn();
    // Google sign out
    Task<Void> googleSignOutTask = taskHelper.getConnectedGoogleApiClient().continueWith(new Continuation<GoogleApiClient, Void>() {

        @Override
        public Void then(@NonNull Task<GoogleApiClient> task) throws Exception {
            if (task.isSuccessful()) {
                Auth.GoogleSignInApi.signOut(task.getResult());
            }
            return null;
        }
    });
    // Facebook sign out
    LoginManager.getInstance().logOut();
    // Wait for all tasks to complete
    return Tasks.whenAll(disableCredentialsTask, googleSignOutTask);
}
Also used : Status(com.google.android.gms.common.api.Status) GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) GoogleApiClientTaskHelper(com.firebase.ui.auth.util.GoogleApiClientTaskHelper) CredentialTaskApi(com.firebase.ui.auth.util.CredentialTaskApi)

Aggregations

CredentialTaskApi (com.firebase.ui.auth.util.CredentialTaskApi)2 GoogleApiClientTaskHelper (com.firebase.ui.auth.util.GoogleApiClientTaskHelper)2 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)1 Status (com.google.android.gms.common.api.Status)1