'How to link Email/Password sign-in method using Firebase admin SDK?
I'm trying to use firebase admin SDK in order to link the Email/Password sign-in method.
Based on firebase documentation we can links user to a specific provider https://firebase.google.com/docs/reference/admin/node/firebase-admin.auth.updaterequest.md#updaterequestprovidertolink
based on that I'm using :
await admin
.auth()
.updateUser(user.uid, {
providerToLink: {
uid: user.email,
email: user.email,
displayName: user.displayName,
providerId: 'password',
},
})
.catch((error: any) => {
console.error(`${error}`);
});
It should link the Email/Password sign-in method to a specific user, but instead of that it's returning error with
- code =
auth/invalid-provider-id - message =
The providerId must be a valid supported provider identifier string.
It's working as expected when the providerId equal to facebook.com or google.com
Question
Is there is another providerId I should use in order to link the Email/Password sign-in method ?
Is there another approach I should use in order to link the Email/Password sign-in method ?
Node version : 12
firebase-admin : 9.12.0
Solution 1:[1]
You need to set providerId as 'email' and also provide password.
await admin.auth().updateUser(user.uid, {
password: "password",
providerToLink: {
email: "[email protected]",
uid: "[email protected]",
providerId: 'email',
},
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Turara |
