Firebase 3.0 令牌:[错误:身份验证标头中的“孩子”声明无效。]

Inc*_*ate 0 token node.js jwt firebase

我正在尝试在 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)

小智 5

请使用 returnSecureToken: true,拼写正确,我希望它能解决 auth 标头中 Invalid claim 'kid' 的问题。