firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

firebase-auth updateUser with providerToLink using "password" as providerId

Open AminAtwi-ITXI opened this issue 3 years ago • 7 comments
trafficstars

Hey I'm trying to link providerData with providerId = "password" using firebase admin SDK

environment :

  • Firebase SDK version: 10.0.2
  • Firebase Product: auth
  • Node.js version: 16.13.0
  • NPM version: 8.1.0

The problem I'm trying to link providerData using firebase admin SDK in order to link providerData with providerId = "password" . I'm using updateUser method and pass providerToLink object in order to link providerData. updateUser method will return this error :

  • code : auth/invalid-provider-id
  • message : The providerId must be a valid supported provider identifier string.

Relevant Code:

await admin
            .auth()
            .updateUser(user.uid, {
                providerToLink: {
                    uid: user.email,
                    email: user.email,
                    displayName: user.displayName,
                    providerId: 'password',
                },
            })
            .catch((error: any) => {
                console.error(`${error}`);
            });

AminAtwi-ITXI avatar Mar 01 '22 07:03 AminAtwi-ITXI

If I understand correctly providerToLink is used when you want to link a user to a specific provider, such as google.com. If you want to set a password to a user you should be able to set it in the updateUser payload. I may have misunderstood your requirement here. Adding @prameshj for more context.

lahirumaramba avatar Mar 08 '22 17:03 lahirumaramba

The list of valid provider ids can be found by invoking this API call - https://cloud.google.com/identity-platform/docs/reference/rest/v2/defaultSupportedIdps/list

In this case, is a password change being attempted?

prameshj avatar Mar 08 '22 21:03 prameshj

Have you found the answer?

tahmassraheem1 avatar Sep 05 '22 09:09 tahmassraheem1

I don't think you can link a password provider directly. You could just call updateUser with the email you want (and the password when you know it).

That's odd because you can unlink a password provider.

MichaelBorde avatar Dec 06 '23 17:12 MichaelBorde