我正在尝试在 node.js 中创建 JWT 令牌以与 firebase 中的 REST api 一起使用,但是当我尝试使用它们时,我收到错误“错误:身份验证标头中的无效声明 '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);
Run Code Online (Sandbox Code Playgroud)
这些是我的要求
var http = require('http');
var jwt = require('jsonwebtoken');
Run Code Online (Sandbox Code Playgroud)