跳至主要内容
REST API 现在已版本化。 有关更多信息,请参阅“关于 API 版本控制”。

GitHub Apps 的 REST API 端点

使用 REST API 与 GitHub Apps 交互

关于 GitHub Apps

如果您正在将您的应用与 GitHub Actions 一起使用,并且想要修改工作流文件,则必须代表用户使用包含 workflow 范围的 OAuth 令牌进行身份验证。用户必须对包含工作流文件的仓库具有管理员或写入权限。有关更多信息,请参阅“OAuth 应用的范围”。

此页面列出了您以 GitHub App 身份进行身份验证时可以访问的端点。有关更多信息,请参阅“以 GitHub App 身份进行身份验证”。

请参阅“GitHub App 安装的 REST API 端点”,以获取需要以 GitHub App 安装身份进行身份验证的端点列表。

获取已认证的应用

返回与所用身份验证凭据关联的 GitHub App。若要查看与此 GitHub App 关联的应用安装数量,请参阅响应中的 installations_count。有关应用安装的更多详细信息,请参阅“列出已认证应用的安装”端点。

您必须使用 JWT 访问此端点。

“获取已认证的应用”的细粒度访问令牌

此端点不适用于 GitHub App 用户访问令牌、GitHub App 安装访问令牌或细粒度个人访问令牌。

“获取已认证的应用”的 HTTP 响应状态代码

状态代码描述
200

OK

“获取已认证的应用”的代码示例

请求示例

get/app
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/app

响应

状态:200
{ "id": 1, "slug": "octoapp", "client_id": "Iv1.ab1112223334445c", "node_id": "MDExOkludGVncmF0aW9uMQ==", "owner": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "name": "Octocat App", "description": "", "external_url": "https://example.com", "html_url": "https://github.com/apps/octoapp", "created_at": "2017-07-08T16:18:44-04:00", "updated_at": "2017-07-08T16:18:44-04:00", "permissions": { "metadata": "read", "contents": "read", "issues": "write", "single_file": "write" }, "events": [ "push", "pull_request" ] }

从清单创建 GitHub App

使用此端点完成在实现 GitHub App 清单流程 时所需的握手。当您使用清单流程创建 GitHub App 时,您会收到一个临时 code,用于检索 GitHub App 的 idpem(私钥)和 webhook_secret

“从清单创建 GitHub App”的细粒度访问令牌

此端点不适用于 GitHub App 用户访问令牌、GitHub App 安装访问令牌或细粒度个人访问令牌。

“从清单创建 GitHub App”的参数

标头
名称、类型、描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
code 字符串 必需

“从清单创建 GitHub App”的 HTTP 响应状态代码

状态代码描述
201

已创建

404

资源未找到

422

验证失败或端点已被滥用。

“从清单创建 GitHub App”的代码示例

请求示例

post/app-manifests/{code}/conversions
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/app-manifests/CODE/conversions

响应

状态:201
{ "id": 1, "slug": "octoapp", "node_id": "MDxOkludGVncmF0aW9uMQ==", "owner": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": true }, "name": "Octocat App", "description": "", "external_url": "https://example.com", "html_url": "https://github.com/apps/octoapp", "created_at": "2017-07-08T16:18:44-04:00", "updated_at": "2017-07-08T16:18:44-04:00", "permissions": { "metadata": "read", "contents": "read", "issues": "write", "single_file": "write" }, "events": [ "push", "pull_request" ], "client_id": "Iv1.8a61f9b3a7aba766", "client_secret": "1726be1638095a19edd134c77bde3aa2ece1e5d8", "webhook_secret": "e340154128314309424b7c8e90325147d99fdafa", "pem": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAuEPzOUE+kiEH1WLiMeBytTEF856j0hOVcSUSUkZxKvqczkWM\n9vo1gDyC7ZXhdH9fKh32aapba3RSsp4ke+giSmYTk2mGR538ShSDxh0OgpJmjiKP\nX0Bj4j5sFqfXuCtl9SkH4iueivv4R53ktqM+n6hk98l6hRwC39GVIblAh2lEM4L/\n6WvYwuQXPMM5OG2Ryh2tDZ1WS5RKfgq+9ksNJ5Q9UtqtqHkO+E63N5OK9sbzpUUm\noNaOl3udTlZD3A8iqwMPVxH4SxgATBPAc+bmjk6BMJ0qIzDcVGTrqrzUiywCTLma\nszdk8GjzXtPDmuBgNn+o6s02qVGpyydgEuqmTQIDAQABAoIBACL6AvkjQVVLn8kJ\ndBYznJJ4M8ECo+YEgaFwgAHODT0zRQCCgzd+Vxl4YwHmKV2Lr+y2s0drZt8GvYva\nKOK8NYYZyi15IlwFyRXmvvykF1UBpSXluYFDH7KaVroWMgRreHcIys5LqVSIb6Bo\ngDmK0yBLPp8qR29s2b7ScZRtLaqGJiX+j55rNzrZwxHkxFHyG9OG+u9IsBElcKCP\nkYCVE8ZdYexfnKOZbgn2kZB9qu0T/Mdvki8yk3I2bI6xYO24oQmhnT36qnqWoCBX\nNuCNsBQgpYZeZET8mEAUmo9d+ABmIHIvSs005agK8xRaP4+6jYgy6WwoejJRF5yd\nNBuF7aECgYEA50nZ4FiZYV0vcJDxFYeY3kYOvVuKn8OyW+2rg7JIQTremIjv8FkE\nZnwuF9ZRxgqLxUIfKKfzp/5l5LrycNoj2YKfHKnRejxRWXqG+ZETfxxlmlRns0QG\nJ4+BYL0CoanDSeA4fuyn4Bv7cy/03TDhfg+Uq0Aeg+hhcPE/vx3ebPsCgYEAy/Pv\neDLssOSdeyIxf0Brtocg6aPXIVaLdus+bXmLg77rJIFytAZmTTW8SkkSczWtucI3\nFI1I6sei/8FdPzAl62/JDdlf7Wd9K7JIotY4TzT7Tm7QU7xpfLLYIP1bOFjN81rk\n77oOD4LsXcosB/U6s1blPJMZ6AlO2EKs10UuR1cCgYBipzuJ2ADEaOz9RLWwi0AH\nPza2Sj+c2epQD9ZivD7Zo/Sid3ZwvGeGF13JyR7kLEdmAkgsHUdu1rI7mAolXMaB\n1pdrsHureeLxGbRM6za3tzMXWv1Il7FQWoPC8ZwXvMOR1VQDv4nzq7vbbA8z8c+c\n57+8tALQHOTDOgQIzwK61QKBgERGVc0EJy4Uag+VY8J4m1ZQKBluqo7TfP6DQ7O8\nM5MX73maB/7yAX8pVO39RjrhJlYACRZNMbK+v/ckEQYdJSSKmGCVe0JrGYDuPtic\nI9+IGfSorf7KHPoMmMN6bPYQ7Gjh7a++tgRFTMEc8956Hnt4xGahy9NcglNtBpVN\n6G8jAoGBAMCh028pdzJa/xeBHLLaVB2sc0Fe7993WlsPmnVE779dAz7qMscOtXJK\nfgtriltLSSD6rTA9hUAsL/X62rY0wdXuNdijjBb/qvrx7CAV6i37NK1CjABNjsfG\nZM372Ac6zc1EqSrid2IjET1YqyIW2KGLI1R2xbQc98UGlt48OdWu\n-----END RSA PRIVATE KEY-----\n" }

列出已认证应用的安装请求

列出已认证 GitHub App 的所有挂起的安装请求。

“列出已认证应用的安装请求”的细粒度访问令牌

此端点不适用于 GitHub App 用户访问令牌、GitHub App 安装访问令牌或细粒度个人访问令牌。

“列出已认证应用的安装请求”的参数

标头
名称、类型、描述
accept 字符串

建议设置为 application/vnd.github+json

查询参数
名称、类型、描述
per_page 整数

每页的结果数(最大 100)。有关更多信息,请参阅“在 REST API 中使用分页”。

默认值: 30

page 整数

要获取的结果的页码。有关更多信息,请参阅“在 REST API 中使用分页”。

默认值: 1

“列出已认证应用的安装请求”的 HTTP 响应状态代码

状态代码描述
200

集成安装请求列表

304

未修改

401

需要身份验证

“列出已认证应用的安装请求”的代码示例

请求示例

get/app/installation-requests
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/app/installation-requests

集成安装请求列表

状态:200
[ { "id": 25381, "node_id": "MDEyOkludGVncmF0aW9uMTIzNDU2Nzg5MA==", "account": { "login": "octo-org", "id": 6811672, "node_id": "MDEyOk9yZ2FuaXphdGlvbjY4MTE2NzI=", "avatar_url": "https://avatars3.githubusercontent.com/u/6811672?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octo-org", "html_url": "https://github.com/octo-org", "followers_url": "https://api.github.com/users/octo-org/followers", "following_url": "https://api.github.com/users/octo-org/following{/other_user}", "gists_url": "https://api.github.com/users/octo-org/gists{/gist_id}", "starred_url": "https://api.github.com/users/octo-org/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octo-org/subscriptions", "organizations_url": "https://api.github.com/users/octo-org/orgs", "repos_url": "https://api.github.com/users/octo-org/repos", "events_url": "https://api.github.com/users/octo-org/events{/privacy}", "received_events_url": "https://api.github.com/users/octo-org/received_events", "type": "Organization", "site_admin": false }, "requester": { "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "created_at": "2022-07-08T16:18:44-04:00" } ]

列出已认证应用的安装

安装具有的权限包含在 permissions 密钥下。

您必须使用 JWT 访问此端点。

“列出已认证应用的安装”的细粒度访问令牌

此端点不适用于 GitHub App 用户访问令牌、GitHub App 安装访问令牌或细粒度个人访问令牌。

“列出已认证应用的安装”的参数

标头
名称、类型、描述
accept 字符串

建议设置为 application/vnd.github+json

查询参数
名称、类型、描述
per_page 整数

每页的结果数(最大 100)。有关更多信息,请参阅“在 REST API 中使用分页”。

默认值: 30

page 整数

要获取的结果的页码。有关更多信息,请参阅“在 REST API 中使用分页”。

默认值: 1

since 字符串

仅显示最后更新时间在给定时间之后的那些结果。这是一个 ISO 8601 格式的时间戳:YYYY-MM-DDTHH:MM:SSZ

outdated 字符串

“列出已认证应用的安装”的 HTTP 响应状态代码

状态代码描述
200

安装具有的权限包含在 permissions 密钥下。

“获取已认证应用的安装信息”代码示例

请求示例

get/app/installations
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/app/installations

安装具有的权限包含在 permissions 密钥下。

状态:200
[ { "id": 1, "account": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "access_tokens_url": "https://api.github.com/app/installations/1/access_tokens", "repositories_url": "https://api.github.com/installation/repositories", "html_url": "https://github.com/organizations/github/settings/installations/1", "app_id": 1, "target_id": 1, "target_type": "Organization", "permissions": { "checks": "write", "metadata": "read", "contents": "read" }, "events": [ "push", "pull_request" ], "single_file_name": "config.yaml", "has_multiple_single_files": true, "single_file_paths": [ "config.yml", ".github/issue_TEMPLATE.md" ], "repository_selection": "selected", "created_at": "2017-07-08T16:18:44-04:00", "updated_at": "2017-07-08T16:18:44-04:00", "app_slug": "github-actions", "suspended_at": null, "suspended_by": null } ]

获取已认证应用的安装信息

使已认证的 GitHub 应用能够使用安装 ID 查找安装信息。

您必须使用 JWT 访问此端点。

“获取已认证应用的安装信息”的细粒度访问令牌

此端点不适用于 GitHub App 用户访问令牌、GitHub App 安装访问令牌或细粒度个人访问令牌。

“获取已认证应用的安装信息”的参数

标头
名称、类型、描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
installation_id 整数 必填

安装的唯一标识符。

“获取已认证应用的安装信息”的 HTTP 响应状态码

状态代码描述
200

OK

404

资源未找到

“获取已认证应用的安装信息”代码示例

请求示例

get/app/installations/{installation_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/app/installations/1

响应

状态:200
{ "id": 1, "account": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "access_tokens_url": "https://api.github.com/app/installations/1/access_tokens", "repositories_url": "https://api.github.com/installation/repositories", "html_url": "https://github.com/organizations/github/settings/installations/1", "app_id": 1, "target_id": 1, "target_type": "Organization", "permissions": { "checks": "write", "metadata": "read", "contents": "read" }, "events": [ "push", "pull_request" ], "single_file_name": "config.yaml", "has_multiple_single_files": true, "single_file_paths": [ "config.yml", ".github/issue_TEMPLATE.md" ], "repository_selection": "selected", "created_at": "2017-07-08T16:18:44-04:00", "updated_at": "2017-07-08T16:18:44-04:00", "app_slug": "github-actions", "suspended_at": null, "suspended_by": null }

删除已认证应用的安装信息

卸载用户、组织或企业帐户上的 GitHub 应用。如果您希望暂时暂停应用对帐户资源的访问,建议使用“暂停应用安装”端点。

您必须使用 JWT 访问此端点。

“删除已认证应用的安装信息”的细粒度访问令牌

此端点不适用于 GitHub App 用户访问令牌、GitHub App 安装访问令牌或细粒度个人访问令牌。

“删除已认证应用的安装信息”的参数

标头
名称、类型、描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
installation_id 整数 必填

安装的唯一标识符。

“删除已认证应用的安装信息”的 HTTP 响应状态码

状态代码描述
204

无内容

404

资源未找到

“删除已认证应用的安装信息”代码示例

请求示例

delete/app/installations/{installation_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/app/installations/1

响应

状态:204

为应用创建安装访问令牌

创建安装访问令牌,使 GitHub 应用能够为其在组织或个人帐户上的安装执行经过身份验证的 API 请求。安装令牌在创建后一小时过期。使用过期的令牌会产生状态码 401 - 未授权,需要创建新的安装令牌。默认情况下,安装令牌可以访问安装可以访问的所有存储库。

可以选择使用 repositoriesrepository_ids 体参数指定安装访问令牌可以访问的单个存储库。如果您不使用 repositoriesrepository_ids 来授予对特定存储库的访问权限,则安装访问令牌将能够访问授予安装访问权限的所有存储库。安装访问令牌无法被授予对未授予安装访问权限的存储库的访问权限。最多可以以这种方式列出 500 个存储库。

可以选择使用 permissions 体参数指定安装访问令牌应具有的权限。如果未指定 permissions,则安装访问令牌将具有授予应用的所有权限。安装访问令牌无法被授予未授予应用的权限。

您必须使用 JWT 访问此端点。

“为应用创建安装访问令牌”的细粒度访问令牌

此端点不适用于 GitHub App 用户访问令牌、GitHub App 安装访问令牌或细粒度个人访问令牌。

“为应用创建安装访问令牌”的参数

标头
名称、类型、描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
installation_id 整数 必填

安装的唯一标识符。

体参数
名称、类型、描述
repositories 字符串数组

令牌应具有访问权限的存储库名称列表

repository_ids 整数数组

令牌应具有访问权限的存储库 ID 列表

permissions 对象

授予用户访问令牌的权限。

名称、类型、描述
actions 字符串

授予访问令牌对 GitHub Actions 工作流、工作流运行和构件的权限级别。

可以是以下之一: read, write

administration 字符串

授予访问令牌对存储库创建、删除、设置、团队和协作者创建的权限级别。

可以是以下之一: read, write

checks 字符串

授予访问令牌对代码检查的权限级别。

可以是以下之一: read, write

codespaces 字符串

授予访问令牌创建、编辑、删除和列出 Codespaces 的权限级别。

可以是以下之一: read, write

contents 字符串

授予访问令牌对存储库内容、提交、分支、下载、发布和合并的权限级别。

可以是以下之一: read, write

dependabot_secrets 字符串

授予访问令牌管理 Dependabot 机密的权限级别。

可以是以下之一: read, write

deployments 字符串

授予访问令牌对部署和部署状态的权限级别。

可以是以下之一: read, write

environments 字符串

授予访问令牌管理存储库环境的权限级别。

可以是以下之一: read, write

issues 字符串

授予访问令牌对问题和相关评论、受让人、标签和里程碑的权限级别。

可以是以下之一: read, write

metadata 字符串

授予访问令牌搜索存储库、列出协作者和访问存储库元数据的权限级别。

可以是以下之一: read, write

packages 字符串

授予访问令牌对发布到 GitHub Packages 的包的权限级别。

可以是以下之一: read, write

pages 字符串

授予访问令牌检索 Pages 状态、配置和构建以及创建新构建的权限级别。

可以是以下之一: read, write

pull_requests 字符串

授予访问令牌对拉取请求和相关评论、受让人、标签、里程碑和合并的权限级别。

可以是以下之一: read, write

repository_custom_properties 字符串

授予访问令牌查看和编辑存储库的自定义属性的权限级别(在属性允许的情况下)。

可以是以下之一: read, write

repository_hooks 字符串

授予访问令牌管理存储库的后接收挂钩的权限级别。

可以是以下之一: read, write

repository_projects 字符串

授予访问令牌管理存储库项目、列和卡片的权限级别。

可以是以下之一: read, write, admin

secret_scanning_alerts 字符串

授予访问令牌查看和管理秘密扫描警报的权限级别。

可以是以下之一: read, write

secrets 字符串

授予访问令牌管理存储库机密的权限级别。

可以是以下之一: read, write

security_events 字符串

授予访问令牌查看和管理安全事件(如代码扫描警报)的权限级别。

可以是以下之一: read, write

single_file 字符串

授予访问令牌以管理单个文件的权限级别。

可以是以下之一: read, write

statuses 字符串

授予访问令牌以管理提交状态的权限级别。

可以是以下之一: read, write

vulnerability_alerts 字符串

授予访问令牌以管理 Dependabot 警报的权限级别。

可以是以下之一: read, write

workflows 字符串

授予访问令牌以更新 GitHub Actions 工作流文件的权限级别。

值: write

members 字符串

授予访问令牌以管理组织团队和成员的权限级别。

可以是以下之一: read, write

organization_administration 字符串

授予访问令牌以管理对组织的访问权限的权限级别。

可以是以下之一: read, write

organization_custom_roles 字符串

授予访问令牌以管理自定义仓库角色的权限级别。

可以是以下之一: read, write

organization_custom_org_roles 字符串

授予访问令牌以管理自定义组织角色的权限级别。

可以是以下之一: read, write

organization_custom_properties 字符串

授予访问令牌以管理自定义属性的权限级别。

可以是以下之一: read, write, admin

organization_copilot_seat_management 字符串

授予访问令牌以管理对拥有 Copilot Business 订阅的组织成员的 GitHub Copilot 的访问权限的权限级别。此属性处于公开预览阶段,可能会发生变化。

值: write

organization_announcement_banners 字符串

授予访问令牌以查看和管理组织公告横幅的权限级别。

可以是以下之一: read, write

organization_events 字符串

授予访问令牌以查看由组织中的活动触发的事件的权限级别。

值: read

organization_hooks 字符串

授予访问令牌以管理组织的 post-receive 钩子的权限级别。

可以是以下之一: read, write

organization_personal_access_tokens 字符串

授予访问令牌以查看和管理对组织的细粒度个人访问令牌请求的权限级别。

可以是以下之一: read, write

organization_personal_access_token_requests 字符串

授予访问令牌以查看和管理已由组织批准的细粒度个人访问令牌的权限级别。

可以是以下之一: read, write

organization_plan 字符串

授予访问令牌以查看组织计划的权限级别。

值: read

organization_projects 字符串

授予访问令牌以管理组织项目和项目公开预览(在可用时)的权限级别。

可以是以下之一: read, write, admin

organization_packages 字符串

授予访问令牌以管理发布到 GitHub Packages 的组织软件包的权限级别。

可以是以下之一: read, write

organization_secrets 字符串

授予访问令牌以管理组织密钥的权限级别。

可以是以下之一: read, write

organization_self_hosted_runners 字符串

授予访问令牌以查看和管理组织可用的 GitHub Actions 自托管运行器的权限级别。

可以是以下之一: read, write

organization_user_blocking 字符串

授予访问令牌以查看和管理组织阻止的用户权限级别。

可以是以下之一: read, write

team_discussions 字符串

授予访问令牌以管理团队讨论和相关评论的权限级别。

可以是以下之一: read, write

email_addresses 字符串

授予访问令牌以管理属于用户的电子邮件地址的权限级别。

可以是以下之一: read, write

followers 字符串

授予访问令牌以管理属于用户的关注者的权限级别。

可以是以下之一: read, write

git_ssh_keys 字符串

授予访问令牌以管理 Git SSH 密钥的权限级别。

可以是以下之一: read, write

gpg_keys 字符串

授予访问令牌以查看和管理属于用户的 GPG 密钥的权限级别。

可以是以下之一: read, write

interaction_limits 字符串

授予访问令牌以查看和管理存储库上的交互限制的权限级别。

可以是以下之一: read, write

profile 字符串

授予访问令牌以管理属于用户的个人资料设置的权限级别。

值: write

starring 字符串

授予访问令牌以列出和管理用户正在加星标的存储库的权限级别。

可以是以下之一: read, write

"为应用创建安装访问令牌" 的 HTTP 响应状态代码

状态代码描述
201

已创建

401

需要身份验证

403

禁止

404

资源未找到

422

验证失败或端点已被滥用。

"为应用创建安装访问令牌" 的代码示例

请求示例

post/app/installations/{installation_id}/access_tokens
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/app/installations/1/access_tokens \ -d '{"repositories":["Hello-World"],"permissions":{"issues":"write","contents":"read"}}'

响应

状态:201
{ "token": "ghs_16C7e42F292c6912E7710c838347Ae178B4a", "expires_at": "2016-07-11T22:14:10Z", "permissions": { "issues": "write", "contents": "read" }, "repository_selection": "selected", "repositories": [ { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World", "owner": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "private": false, "html_url": "https://github.com/octocat/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octocat/Hello-World", "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads", "events_url": "https://api.github.com/repos/octocat/Hello-World/events", "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octocat/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages", "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}", "ssh_url": "git@github.com:octocat/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags", "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams", "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", "clone_url": "https://github.com/octocat/Hello-World.git", "mirror_url": "git:git.example.com/octocat/Hello-World", "hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks", "svn_url": "https://svn.github.com/octocat/Hello-World", "homepage": "https://github.com", "language": null, "forks_count": 9, "stargazers_count": 80, "watchers_count": 80, "size": 108, "default_branch": "master", "open_issues_count": 0, "is_template": true, "topics": [ "octocat", "atom", "electron", "api" ], "has_issues": true, "has_projects": true, "has_wiki": true, "has_pages": false, "has_downloads": true, "archived": false, "disabled": false, "visibility": "public", "pushed_at": "2011-01-26T19:06:43Z", "created_at": "2011-01-26T19:01:12Z", "updated_at": "2011-01-26T19:14:43Z", "permissions": { "admin": false, "push": false, "pull": true }, "allow_rebase_merge": true, "template_repository": null, "temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O", "allow_squash_merge": true, "allow_auto_merge": false, "delete_branch_on_merge": true, "allow_merge_commit": true, "subscribers_count": 42, "network_count": 0, "license": { "key": "mit", "name": "MIT License", "url": "https://api.github.com/licenses/mit", "spdx_id": "MIT", "node_id": "MDc6TGljZW5zZW1pdA==", "html_url": "https://github.com/licenses/mit" }, "forks": 1, "open_issues": 1, "watchers": 1 } ] }

暂停应用安装

暂停用户、组织或企业帐户上的 GitHub 应用,这会阻止应用访问帐户的资源。当 GitHub 应用被暂停时,该应用对 GitHub API 或 Webhook 事件的访问权限将被阻止。

您必须使用 JWT 访问此端点。

"暂停应用安装" 的细粒度访问令牌

此端点不适用于 GitHub App 用户访问令牌、GitHub App 安装访问令牌或细粒度个人访问令牌。

"暂停应用安装" 的参数

标头
名称、类型、描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
installation_id 整数 必填

安装的唯一标识符。

"暂停应用安装" 的 HTTP 响应状态代码

状态代码描述
204

无内容

404

资源未找到

"暂停应用安装" 的代码示例

请求示例

put/app/installations/{installation_id}/suspended
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/app/installations/1/suspended

响应

状态:204

取消暂停应用安装

移除 GitHub 应用安装暂停。

您必须使用 JWT 访问此端点。

"取消暂停应用安装" 的细粒度访问令牌

此端点不适用于 GitHub App 用户访问令牌、GitHub App 安装访问令牌或细粒度个人访问令牌。

"取消暂停应用安装" 的参数

标头
名称、类型、描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
installation_id 整数 必填

安装的唯一标识符。

"取消暂停应用安装" 的 HTTP 响应状态代码

状态代码描述
204

无内容

404

资源未找到

"取消暂停应用安装" 的代码示例

请求示例

delete/app/installations/{installation_id}/suspended
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/app/installations/1/suspended

响应

状态:204

创建作用域访问令牌

使用非作用域用户访问令牌创建存储库作用域和/或权限作用域的用户访问令牌。您可以指定令牌可以访问哪些存储库以及授予令牌哪些权限。

无效的令牌将返回 404 NOT FOUND

“创建作用域访问令牌”的基本身份验证

您必须使用 基本身份验证 来使用此端点。使用应用程序的 client_id 作为用户名,使用 client_secret 作为密码。

“创建作用域访问令牌”的参数

标头
名称、类型、描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
client_id 字符串 必需

GitHub 应用程序的客户端 ID。

体参数
名称、类型、描述
access_token 字符串 必需

用于向 GitHub API 进行身份验证的访问令牌。

target 字符串

将用户访问令牌的作用域限定到用户或组织的名称。除非指定了 target_id否则必需

target_id 整数

将用户访问令牌的作用域限定到用户或组织的 ID。除非指定了 target否则必需

repositories 字符串数组

将用户访问令牌的作用域限定到的存储库名称列表。如果指定了 repository_ids,则不能指定 repositories

repository_ids 整数数组

将用户访问令牌的作用域限定到的存储库 ID 列表。如果指定了 repositories,则不能指定 repository_ids

permissions 对象

授予用户访问令牌的权限。

名称、类型、描述
actions 字符串

授予访问令牌对 GitHub Actions 工作流、工作流运行和构件的权限级别。

可以是以下之一: read, write

administration 字符串

授予访问令牌对存储库创建、删除、设置、团队和协作者创建的权限级别。

可以是以下之一: read, write

checks 字符串

授予访问令牌对代码检查的权限级别。

可以是以下之一: read, write

codespaces 字符串

授予访问令牌创建、编辑、删除和列出 Codespaces 的权限级别。

可以是以下之一: read, write

contents 字符串

授予访问令牌对存储库内容、提交、分支、下载、发布和合并的权限级别。

可以是以下之一: read, write

dependabot_secrets 字符串

授予访问令牌管理 Dependabot 机密的权限级别。

可以是以下之一: read, write

deployments 字符串

授予访问令牌对部署和部署状态的权限级别。

可以是以下之一: read, write

environments 字符串

授予访问令牌管理存储库环境的权限级别。

可以是以下之一: read, write

issues 字符串

授予访问令牌对问题和相关评论、受让人、标签和里程碑的权限级别。

可以是以下之一: read, write

metadata 字符串

授予访问令牌搜索存储库、列出协作者和访问存储库元数据的权限级别。

可以是以下之一: read, write

packages 字符串

授予访问令牌对发布到 GitHub Packages 的包的权限级别。

可以是以下之一: read, write

pages 字符串

授予访问令牌检索 Pages 状态、配置和构建以及创建新构建的权限级别。

可以是以下之一: read, write

pull_requests 字符串

授予访问令牌对拉取请求和相关评论、受让人、标签、里程碑和合并的权限级别。

可以是以下之一: read, write

repository_custom_properties 字符串

授予访问令牌查看和编辑存储库的自定义属性的权限级别(在属性允许的情况下)。

可以是以下之一: read, write

repository_hooks 字符串

授予访问令牌管理存储库的后接收挂钩的权限级别。

可以是以下之一: read, write

repository_projects 字符串

授予访问令牌管理存储库项目、列和卡片的权限级别。

可以是以下之一: read, write, admin

secret_scanning_alerts 字符串

授予访问令牌查看和管理秘密扫描警报的权限级别。

可以是以下之一: read, write

secrets 字符串

授予访问令牌管理存储库机密的权限级别。

可以是以下之一: read, write

security_events 字符串

授予访问令牌查看和管理安全事件(如代码扫描警报)的权限级别。

可以是以下之一: read, write

single_file 字符串

授予访问令牌以管理单个文件的权限级别。

可以是以下之一: read, write

statuses 字符串

授予访问令牌以管理提交状态的权限级别。

可以是以下之一: read, write

vulnerability_alerts 字符串

授予访问令牌以管理 Dependabot 警报的权限级别。

可以是以下之一: read, write

workflows 字符串

授予访问令牌以更新 GitHub Actions 工作流文件的权限级别。

值: write

members 字符串

授予访问令牌以管理组织团队和成员的权限级别。

可以是以下之一: read, write

organization_administration 字符串

授予访问令牌以管理对组织的访问权限的权限级别。

可以是以下之一: read, write

organization_custom_roles 字符串

授予访问令牌以管理自定义仓库角色的权限级别。

可以是以下之一: read, write

organization_custom_org_roles 字符串

授予访问令牌以管理自定义组织角色的权限级别。

可以是以下之一: read, write

organization_custom_properties 字符串

授予访问令牌以管理自定义属性的权限级别。

可以是以下之一: read, write, admin

organization_copilot_seat_management 字符串

授予访问令牌以管理对拥有 Copilot Business 订阅的组织成员的 GitHub Copilot 的访问权限的权限级别。此属性处于公开预览阶段,可能会发生变化。

值: write

organization_announcement_banners 字符串

授予访问令牌以查看和管理组织公告横幅的权限级别。

可以是以下之一: read, write

organization_events 字符串

授予访问令牌以查看由组织中的活动触发的事件的权限级别。

值: read

organization_hooks 字符串

授予访问令牌以管理组织的 post-receive 钩子的权限级别。

可以是以下之一: read, write

organization_personal_access_tokens 字符串

授予访问令牌以查看和管理对组织的细粒度个人访问令牌请求的权限级别。

可以是以下之一: read, write

organization_personal_access_token_requests 字符串

授予访问令牌以查看和管理已由组织批准的细粒度个人访问令牌的权限级别。

可以是以下之一: read, write

organization_plan 字符串

授予访问令牌以查看组织计划的权限级别。

值: read

organization_projects 字符串

授予访问令牌以管理组织项目和项目公开预览(在可用时)的权限级别。

可以是以下之一: read, write, admin

organization_packages 字符串

授予访问令牌以管理发布到 GitHub Packages 的组织软件包的权限级别。

可以是以下之一: read, write

organization_secrets 字符串

授予访问令牌以管理组织密钥的权限级别。

可以是以下之一: read, write

organization_self_hosted_runners 字符串

授予访问令牌以查看和管理组织可用的 GitHub Actions 自托管运行器的权限级别。

可以是以下之一: read, write

organization_user_blocking 字符串

授予访问令牌以查看和管理组织阻止的用户权限级别。

可以是以下之一: read, write

team_discussions 字符串

授予访问令牌以管理团队讨论和相关评论的权限级别。

可以是以下之一: read, write

email_addresses 字符串

授予访问令牌以管理属于用户的电子邮件地址的权限级别。

可以是以下之一: read, write

followers 字符串

授予访问令牌以管理属于用户的关注者的权限级别。

可以是以下之一: read, write

git_ssh_keys 字符串

授予访问令牌以管理 Git SSH 密钥的权限级别。

可以是以下之一: read, write

gpg_keys 字符串

授予访问令牌以查看和管理属于用户的 GPG 密钥的权限级别。

可以是以下之一: read, write

interaction_limits 字符串

授予访问令牌以查看和管理存储库上的交互限制的权限级别。

可以是以下之一: read, write

profile 字符串

授予访问令牌以管理属于用户的个人资料设置的权限级别。

值: write

starring 字符串

授予访问令牌以列出和管理用户正在加星标的存储库的权限级别。

可以是以下之一: read, write

“创建作用域访问令牌”的 HTTP 响应状态代码

状态代码描述
200

OK

401

需要身份验证

403

禁止

404

资源未找到

422

验证失败或端点已被滥用。

“创建作用域访问令牌”的代码示例

请求示例

post/applications/{client_id}/token/scoped
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -u "<YOUR_CLIENT_ID>:<YOUR_CLIENT_SECRET>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/applications/Iv1.8a61f9b3a7aba766/token/scoped \ -d '{"access_token":"e72e16c7e42f292c6912e7710c838347ae178b4a","target":"octocat","permissions":{"metadata":"read","issues":"write","contents":"read"}}'

响应

状态:200
{ "id": 1, "url": "https://api.github.com/authorizations/1", "scopes": [], "token": "ghu_16C7e42F292c6912E7710c838347Ae178B4a", "token_last_eight": "Ae178B4a", "hashed_token": "25f94a2a5c7fbaf499c665bc73d67c1c87e496da8985131633ee0a95819db2e8", "app": { "url": "http://my-github-app.com", "name": "my github app", "client_id": "Iv1.8a61f9b3a7aba766" }, "note": "optional note", "note_url": "http://optional/note/url", "updated_at": "2011-09-06T20:39:23Z", "created_at": "2011-09-06T17:26:27Z", "fingerprint": "jklmnop12345678", "expires_at": "2011-09-08T17:26:27Z", "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "installation": { "permissions": { "metadata": "read", "issues": "write", "contents": "read" }, "repository_selection": "selected", "single_file_name": ".github/workflow.yml", "repositories_url": "https://api.github.com/user/repos", "account": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "has_multiple_single_files": false, "single_file_paths": [] } }

获取应用程序

注意

:app_slug 只是 GitHub 应用程序的 URL 友好名称。您可以在 GitHub 应用程序的设置页面上找到它(例如,https://github.com/settings/apps/:app_slug)。

“获取应用程序”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

如果仅请求公共资源,则可以在未进行身份验证的情况下使用此端点。

“获取应用程序”的参数

标头
名称、类型、描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
app_slug 字符串 必需

“获取应用程序”的 HTTP 响应状态代码

状态代码描述
200

OK

403

禁止

404

资源未找到

“获取应用程序”的代码示例

请求示例

get/apps/{app_slug}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/apps/APP_SLUG

响应

状态:200
{ "id": 1, "slug": "octoapp", "client_id": "Iv1.ab1112223334445c", "node_id": "MDExOkludGVncmF0aW9uMQ==", "owner": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "name": "Octocat App", "description": "", "external_url": "https://example.com", "html_url": "https://github.com/apps/octoapp", "created_at": "2017-07-08T16:18:44-04:00", "updated_at": "2017-07-08T16:18:44-04:00", "permissions": { "metadata": "read", "contents": "read", "issues": "write", "single_file": "write" }, "events": [ "push", "pull_request" ] }

获取经过身份验证的应用程序的组织安装

使经过身份验证的 GitHub 应用程序能够查找组织的安装信息。

您必须使用 JWT 访问此端点。

“获取经过身份验证的应用程序的组织安装”的细粒度访问令牌

此端点不适用于 GitHub App 用户访问令牌、GitHub App 安装访问令牌或细粒度个人访问令牌。

“获取经过身份验证的应用程序的组织安装”的参数

标头
名称、类型、描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
org 字符串 必需

组织名称。名称不区分大小写。

“获取经过身份验证的应用程序的组织安装”的 HTTP 响应状态代码

状态代码描述
200

OK

“获取经过身份验证的应用程序的组织安装”的代码示例

请求示例

get/orgs/{org}/installation
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/installation

响应

状态:200
{ "id": 1, "account": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "avatar_url": "https://github.com/images/error/hubot_happy.gif", "gravatar_id": "", "url": "https://api.github.com/orgs/github", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "received_events_url": "https://api.github.com/users/github/received_events", "type": "Organization", "site_admin": false }, "repository_selection": "all", "access_tokens_url": "https://api.github.com/app/installations/1/access_tokens", "repositories_url": "https://api.github.com/installation/repositories", "html_url": "https://github.com/organizations/github/settings/installations/1", "app_id": 1, "client_id": "Iv1.ab1112223334445c", "target_id": 1, "target_type": "Organization", "permissions": { "checks": "write", "metadata": "read", "contents": "read" }, "events": [ "push", "pull_request" ], "created_at": "2018-02-09T20:51:14Z", "updated_at": "2018-02-09T20:51:14Z", "single_file_name": "config.yml", "has_multiple_single_files": true, "single_file_paths": [ "config.yml", ".github/issue_TEMPLATE.md" ], "app_slug": "github-actions", "suspended_at": null, "suspended_by": null }

获取经过身份验证的应用程序的存储库安装

使经过身份验证的 GitHub 应用程序能够查找存储库的安装信息。根据存储库所属的帐户,安装的帐户类型将是组织或用户帐户。

您必须使用 JWT 访问此端点。

“获取经过身份验证的应用程序的存储库安装”的细粒度访问令牌

此端点不适用于 GitHub App 用户访问令牌、GitHub App 安装访问令牌或细粒度个人访问令牌。

“获取经过身份验证的应用程序的存储库安装”的参数

标头
名称、类型、描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
owner 字符串 必需

存储库的帐户所有者。名称不区分大小写。

repo 字符串 必需

存储库的名称,不带 .git 扩展名。名称不区分大小写。

“获取经过身份验证的应用程序的存储库安装”的 HTTP 响应状态代码

状态代码描述
200

OK

301

永久移动

404

资源未找到

“获取经过身份验证的应用程序的存储库安装”的代码示例

请求示例

get/repos/{owner}/{repo}/installation
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/installation

响应

状态:200
{ "id": 1, "account": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "avatar_url": "https://github.com/images/error/hubot_happy.gif", "gravatar_id": "", "url": "https://api.github.com/orgs/github", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "received_events_url": "https://api.github.com/users/github/received_events", "type": "Organization", "site_admin": false }, "repository_selection": "all", "access_tokens_url": "https://api.github.com/app/installations/1/access_tokens", "repositories_url": "https://api.github.com/installation/repositories", "html_url": "https://github.com/organizations/github/settings/installations/1", "app_id": 1, "client_id": "Iv1.ab1112223334445c", "target_id": 1, "target_type": "Organization", "permissions": { "checks": "write", "metadata": "read", "contents": "read" }, "events": [ "push", "pull_request" ], "created_at": "2018-02-09T20:51:14Z", "updated_at": "2018-02-09T20:51:14Z", "single_file_name": "config.yml", "has_multiple_single_files": true, "single_file_paths": [ "config.yml", ".github/issue_TEMPLATE.md" ], "app_slug": "github-actions", "suspended_at": null, "suspended_by": null }

获取经过身份验证的应用程序的用户安装

使经过身份验证的 GitHub 应用程序能够查找用户的安装信息。

您必须使用 JWT 访问此端点。

“获取经过身份验证的应用程序的用户安装”的细粒度访问令牌

此端点不适用于 GitHub App 用户访问令牌、GitHub App 安装访问令牌或细粒度个人访问令牌。

“获取经过身份验证的应用程序的用户安装”的参数

标头
名称、类型、描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
username 字符串 必需

GitHub 用户帐户的句柄。

“获取经过身份验证的应用程序的用户安装”的 HTTP 响应状态代码

状态代码描述
200

OK

“获取经过身份验证的应用程序的用户安装”的代码示例

请求示例

get/users/{username}/installation
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/users/USERNAME/installation

响应

状态:200
{ "id": 1, "account": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "avatar_url": "https://github.com/images/error/hubot_happy.gif", "gravatar_id": "", "url": "https://api.github.com/orgs/github", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "received_events_url": "https://api.github.com/users/github/received_events", "type": "Organization", "site_admin": false }, "repository_selection": "all", "access_tokens_url": "https://api.github.com/app/installations/1/access_tokens", "repositories_url": "https://api.github.com/installation/repositories", "html_url": "https://github.com/organizations/github/settings/installations/1", "app_id": 1, "client_id": "Iv1.ab1112223334445c", "target_id": 1, "target_type": "Organization", "permissions": { "checks": "write", "metadata": "read", "contents": "read" }, "events": [ "push", "pull_request" ], "created_at": "2018-02-09T20:51:14Z", "updated_at": "2018-02-09T20:51:14Z", "single_file_name": "config.yml", "has_multiple_single_files": true, "single_file_paths": [ "config.yml", ".github/issue_TEMPLATE.md" ], "app_slug": "github-actions", "suspended_at": null, "suspended_by": null }