【问题标题】:Firebase console shows empty identifier for custom authenticationFirebase 控制台显示自定义身份验证的空标识符
【发布时间】:2018-12-29 00:28:37
【问题描述】:

我为 Firebase 使用自定义身份验证方案。令牌由我的nodejs 后端生成:

mFirebase
        .getAuth(token)
        .createCustomToken(uid, claims)
        .then(sendToken)
        .
        .

当我查看 Firebase 控制台的“用户”部分时,“标识符”字段始终为空。

我想知道这是否是预期的行为,或者我可以从我的后端提供额外的东西,例如用户名或电子邮件,以显示在那里。

【问题讨论】:

    标签: node.js firebase firebase-authentication


    【解决方案1】:

    这是意料之中的。如果要显示,您需要在用户上设置电子邮件。 您有 2 个选项。

    在您铸造自定义令牌之前设置:

    return admin.auth().createUser({
      uid: 'customUserUid',
      email: 'user@example.com'
    }).then((userRecord) => {
      return admin.auth().createCustomToken(userRecord.uid);
    }).catch((error) => {
      // Error.
    });
    

    登录后更新用户电子邮件客户端:

    firebase.auth().signInWithCustomToken(customToken).then((result) => {
      return result.user.updateEmail(userEmail);
    }).catch((error) => {
      // Error.
    });
    

    【讨论】:

      猜你喜欢
      • 2017-10-29
      • 2020-04-01
      • 2022-12-10
      • 2017-12-10
      • 2020-10-12
      • 1970-01-01
      • 1970-01-01
      • 2016-07-09
      • 1970-01-01
      相关资源
      最近更新 更多