问题描述
我创建了一个 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
。
为什么搜索失败了?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)