我正在尝试在 node.js 中创建 JWT token 以与 firebase 中的 REST api 一起使用,但是当我尝试使用它们时,我收到错误消息“错误:auth header 中的无效声明'kid'。”
这是我的代码
http.createServer(function (req, res) {
var payload = {
uid: "bruh"
};
var token = jwt.sign(payload, sact["private_key"], {
algorithm: 'RS256',
issuer: sact["client_email"],
subject: sact["client_email"],
audience: 'https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit',
expiresIn: '3600s',
jwtid: sact["private_key_id"],
header: {
"kid": sact["private_key_id"]
}
});
res.writeHead(200);
res.end("It worked. (" + token + ")");
}).listen(port);
这是我的要求
var http = require('http');
var jwt = require('jsonwebtoken');
最佳答案
请使用 returnSecureToken: true,拼写正确 我希望它能解决 auth header 中 Invalid claim 'kid' 的问题。
关于node.js - Firebase 3.0 token : [Error: Invalid claim 'kid' in auth header.],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37913121/