Github使用授权给Github应用程序的访问令牌进行身份验证,以便列出安装



我试图从github获取安装列表。

我已经生成了给定文档中提到的访问令牌。https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps 2-users-are-redirected-back-to-your-site-by-github

现在我使用相同的访问令牌来调用安装api下面的api。(将认证值传递为"承载者"。

https://api.github.com/user/installations

这些信息在以下链接中给出。https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps check-which-installations-resources-a-user-can-access

当我尝试点击安装api时,它给出以下错误:

You must authenticate with an access token authorized to a GitHub App in order to list installations

基本上我试图实现以下步骤给出的文件:https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps#web-application-flow和https://docs.github.com/en/rest/reference/apps list-app-installations-accessible-to-the-user-access-token

确保你创建的Github应用程序实际上是一个Github应用程序而不是一个OAuth应用程序. 您可以通过确保它在这个页面上列出来检查:https://github.com/organizations/{your-organization-id}/settings/apps.

用于触发操作的访问令牌必须是使用这个Github应用程序请求的(客户端id在关于部分https://github.com/organizations/{your-organization-id}/settings/apps/{app-id})。