【问题标题】:Code=17000 "The custom token format is incorrect. Please check the documentation."Code=17000 "自定义令牌格式不正确。请检查文档。"
【发布时间】:2018-01-06 06:24:57
【问题描述】:

我按照此处描述的步骤操作:https://firebase.google.com/docs/auth/admin/create-custom-tokens

我可以使用 Firebase Admin SDK 创建自定义令牌。

我将它们发送回客户端 iOS 应用程序以像这样使用:

Auth.auth().signIn(withCustomToken: customToken ?? "") { (user, error) in
  // ...
}

但我收到此错误:

Code=17000 "The custom token format is incorrect. Please check the documentation." UserInfo={NSLocalizedDescription=The custom token format is incorrect. Please check the documentation., error_name=ERROR_INVALID_CUSTOM_TOKEN}

我正在使用 Firebase Admin 5.2.0 和 Firebase iOS 客户端 4.0.0

有什么想法吗?

【问题讨论】:

  • 查看这篇文章以了解如何调试它:stackoverflow.com/questions/45110441/… 请记住,自定义令牌的生命周期是有限的,如果您存储和重用它,它可能会过期。
  • 如果它已过期,我已经设法请求更新,但我的问题是令牌永远无法工作
  • 好的,想把它排除在外。检查该链接中描述的自定义令牌的解码格式。
  • @bojeil 使用调试器 jwt.io 使用正确的数据正确解码令牌
  • 确保客户端项目与生成该自定义令牌的服务帐户匹配。尝试使用 REST API 发送令牌:firebase.google.com/docs/reference/rest/auth/… 如果这没有帮助,您应该联系 Firebase 支持。

标签: firebase firebase-authentication


【解决方案1】:

我尝试了很多时间来解决它。我发现了一些有趣的东西。 custom_toke 以 "%3D%3D" 结尾,这是无效的,你需要用 "==".. 替换 is,它会很好用。

【讨论】:

    【解决方案2】:

    检查令牌及其生命周期后,我们发现系统时间不匹配是我们案例中的问题。

    将时区和时间设置为“自动”后,问题就解决了。

    【讨论】:

    • 您能告诉我您在哪里将此选项设置为“自动”吗?我面临同样的问题,我的服务器提前 4 分钟生成令牌。
    • 自动是关于使用网络时间 - 与 NTP 同步。
    猜你喜欢
    • 2019-12-21
    • 2018-10-16
    • 1970-01-01
    • 2017-02-08
    • 2016-12-04
    • 2017-02-16
    • 1970-01-01
    • 2017-07-11
    • 2016-05-04
    相关资源
    最近更新 更多