如何使用Firebase管理SDK链接电子邮件/密码登录方法



我正在尝试使用firebase管理SDK来链接电子邮件/密码登录方法。

基于firebase文档,我们可以将用户链接到特定的提供商https://firebase.google.com/docs/reference/admin/node/firebase-admin.auth.updaterequest.md#updaterequestprovidertolink


基于我使用的:

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

它应该将电子邮件/密码登录方法链接到特定用户,但不是这样,它会返回错误

  • code=auth/invalid-provider-id
  • 消息=The providerId must be a valid supported provider identifier string.

当providerId等于facebook.comgoogle.com时,它按预期工作

问题

是否有其他提供商我应该使用它来链接电子邮件/密码登录方法?

我是否应该使用其他方法来链接电子邮件/密码登录方法?


节点版本:12

firebase管理员:9.12.0

您需要将providerId设置为'email'并提供密码。

await admin.auth().updateUser(user.uid, {
password: "password",
providerToLink: {
email: "example@example.com",
uid: "example@example.com",
providerId: 'email',
},
})

最新更新