Search code examples
firebase-authenticationfirebase-admin

firebase: Delete a provider using admin sdk


Using Admin-sdk, Is there a way to delete a particular provider from a user record in firebase?

For eg: Assume a given user has the following providers linked to his account

  1. password
  2. google.com
  3. facebook.com

Say, I would like to revoke the user's ability to login via facebook to his account. Can this be done using admin sdk.

I could only find an api to unlink a provider (which is client side api. This will require the firebase-issued-idToken of the user).


Solution

  • Not sure when this ability was added in admin sdk, but it seems in version 8.1.0 you can achieve this using the following:

    UserRecord.UpdateRequest updateRequest = new UserRecord.UpdateRequest(ssoId);
    // remove/unlink social login providers
    updateRequest.setProvidersToUnlink(Arrays.asList("google.com", "facebook.com", "apple.com"));            
    
    FirebaseAuth.getInstance().updateUser(updateRequest);