【问题标题】:Firebase verifyIdToken hangsFirebase verifyIdToken 挂起
【发布时间】:2016-10-02 01:31:35
【问题描述】:

当我尝试验证在我的 Node.js 服务器上的前端生成的令牌时,该函数会永远挂起。这是我的代码:

const firebase = require('firebase').initializeApp({
  serviceAccount: '******************.json',
  databaseURL: "https://**********************.firebaseio.com",
}, 'admin')

router.get('/', (req, res) => {
  co(function*(){

    // Verify token. Returns decoded token
    const token = yield firebase.auth().verifyIdToken(req.cookies.firebase_token)

    res.render('index')
  })
    .catch(err => {
      throw err
    })
})

我正在使用来自 npm 和 node -v 6.2.2 的 Firebase 3.4.1。

【问题讨论】:

    标签: node.js firebase token


    【解决方案1】:

    我在 cookie 中发送了错误的数据。使用firebase.auth().currentUser.getToken(true) 函数获取正确的令牌。

    【讨论】:

    • 这不应该是挂起的原因。如果令牌无效,它将返回 Decoding Firebase ID token failed. Make sure you passed the entire string JWT which represents an ID token
    猜你喜欢
    • 2019-05-14
    • 1970-01-01
    • 2021-08-21
    • 2018-02-20
    • 1970-01-01
    • 2017-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多