【发布时间】:2021-07-07 05:57:45
【问题描述】:
我创建了一个 GitHub 应用程序并将其安装在我的帐户中,使其能够访问我帐户中的私有存储库。 GitHub 应用程序具有元数据的读取权限。 然后,我按照此处的步骤生成了一个 JWT 并使用它来创建安装访问令牌。 我尝试使用这个令牌在上面的私有存储库中使用 GitHub 搜索 API 搜索关键字,如下所示:
https://api.github.com/search/code?q=abc+in:file+repo:username/private-repo
但是,这会返回以下响应。
{
"message": "Validation Failed",
"errors": [
{
"message": "The listed users and repositories cannot be searched either because the resources do not exist or you do not have permission to view them.",
"resource": "Search",
"field": "q",
"code": "invalid"
}
],
"documentation_url": "https://docs.github.com/v3/search/"
}
我尝试使用此访问令牌来获取此 GitHub 应用安装的存储库,并在响应中成功返回了私有存储库。我认为这意味着安装可以访问私有仓库并且令牌按预期工作。
使用的 API:https://api.github.com/installation/repositories。
那为什么搜索会失败呢?
【问题讨论】:
标签: github-api-v3 octokit.net github-app