Jwt 无法使用应用令牌对api.github.com进行身份验证
我尝试按照此处的说明将JWT识别为api.github.com上的应用程序: 我不知道我做错了什么,但我总是得到“坏证书”。 有人能看一下我的代码并找出答案吗?(节点JS)Jwt 无法使用应用令牌对api.github.com进行身份验证,jwt,token,github-api,Jwt,Token,Github Api,我尝试按照此处的说明将JWT识别为api.github.com上的应用程序: 我不知道我做错了什么,但我总是得到“坏证书”。 有人能看一下我的代码并找出答案吗?(节点JS) 看看文档是否有用。它看起来与我使用的链接相同。。。 var fs = require('fs'); var jwt = require('jsonwebtoken'); var privateKey = fs.readFileSync('doronsaartestapp.pem'); var token = jwt.sig
看看文档是否有用。它看起来与我使用的链接相同。。。
var fs = require('fs');
var jwt = require('jsonwebtoken');
var privateKey = fs.readFileSync('doronsaartestapp.pem');
var token = jwt.sign(
{
iat: new Date().getTime() / 1000,
exp: new Date().getTime() / 1000 + 10*60,
iss: 'Iv1.5a751653c88a7cd2'//84487
},
privateKey,
{algorithm: 'RS256'}
);
console.log('token: ' + token);
var http = require('https');
var options = {
host: 'api.github.com',
path: '/repos/doronsaar/panther-proxy/hooks',
headers: {
'Accept': 'application/vnd.github.v3.raw+json',
'Authorization': 'Bearer ' + token,
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36'
}
};
callback = function(response) {
console.log("response status code: " + response.statusCode);
var str = '';
//another chunk of data has been received, so append it to `str`
response.on('data', function (chunk) {
console.log(chunk.toString());
});
//the whole response has been received, so we just print it out here
response.on('end', function () {
console.log("--end--");
});
}
http.request(options, callback).end();