[英]How to access Private Repository through GitHub API?
根据文档,我可以访问这样的公共存储库:
GET /repos/:owner/:repo
但是如何访问私有仓库?
我创建了一个令牌,它可以访问我的所有存储库并将其添加到标题中,但问题仍然存在。
我的代码:
const https = require('https');
const oAuth = require('oauth');
const owner = '<owner>';
const repo = '<repo>';
let data = '';
const options = {
host: 'api.github.com',
path: '/repos/' + owner + '/' + repo,
method: 'GET',
headers: {
'user-agent': '<myGitHubAccount>',
'authorization': 'token <token>'
}
};
const request = https.request(options, function (response) {
var body = '';
response.on("data", function (chunk) {
body += chunk.toString('utf8');
});
response.on("end", function () {
console.log(body);
});
});
request.end();
安慰:
{"message":"Not Found","documentation_url":"https://developer.github.com/v3/repos/#get"}
提前致谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.