firebase: Delete a provider using admin sdk

Viewed 32

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).

2 Answers

I don't think there's an API to unlink a provider in the Admin SDK. It does exist in the REST API, but there too it seems to only exist for the current user.

But I also don't think it would help much, as the user can always call the API to link that provider with your configuration data - even if your application code doesn't. So while it is useful to be able to unlink a provider from your code, it won't be a permanent revoke, which seems to be what you're after. That would only be possible for all users by disabling the Facebook provider completely.

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);
Related