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

用于 Codespaces 用户密钥的 REST API 端点

使用 REST API 管理用户在 codespace 中有权访问的密钥。

关于 Codespaces 用户密钥

您可以创建、列出和删除密钥(例如云服务的访问令牌),以及将密钥分配给用户有权访问的存储库。这些密钥在运行时提供给 codespace。有关更多信息,请参阅“管理您针对 GitHub Codespaces 的帐户特定密钥”。

列出经过身份验证的用户的密钥

列出用户 codespace 可用的所有开发环境密钥,但不显示其加密值。

经过身份验证的用户必须具有 Codespaces 访问权限才能使用此端点。

OAuth 应用令牌和个人访问令牌(经典)需要 codespacecodespace:secrets 范围才能使用此端点。

用于“列出经过身份验证的用户的密钥”的细粒度访问令牌

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

细粒度令牌必须具有以下权限集

  • “Codespaces 用户密钥”用户权限(读取)

用于“列出经过身份验证的用户的密钥”的参数

标头
名称、类型、描述
accept string

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

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

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

默认: 30

page 整数

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

默认: 1

“列出经过身份验证用户的秘密”的 HTTP 响应状态代码

状态代码描述
200

OK

“列出经过身份验证用户的秘密”的代码示例

请求示例

get/user/codespaces/secrets
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/user/codespaces/secrets

响应

状态:200
{ "total_count": 2, "secrets": [ { "name": "GH_TOKEN", "created_at": "2019-08-10T14:59:22Z", "updated_at": "2020-01-10T14:59:22Z", "visibility": "all" }, { "name": "GIST_ID", "created_at": "2020-01-10T10:59:22Z", "updated_at": "2020-01-11T11:59:22Z", "visibility": "all" } ] }

获取经过身份验证用户的公钥

获取您的公钥,您需要使用它来加密秘密。您需要在创建或更新秘密之前加密秘密。

经过身份验证的用户必须具有 Codespaces 访问权限才能使用此端点。

OAuth 应用令牌和个人访问令牌(经典)需要 codespacecodespace:secrets 范围才能使用此端点。

“获取经过身份验证用户的公钥”的细粒度访问令牌

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

细粒度令牌必须具有以下权限集

  • “Codespaces 用户密钥”用户权限(读取)

“获取经过身份验证用户的公钥”的 HTTP 响应状态代码

状态代码描述
200

OK

“获取经过身份验证用户的公钥”的代码示例

请求示例

获取/user/codespaces/secrets/public-key
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/user/codespaces/secrets/public-key

响应

状态:200
{ "key_id": "012345678912345678", "key": "2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234" }

获取已认证用户的密钥

获取用户代码空间可用的开发环境密钥,不会泄露其加密值。

经过身份验证的用户必须具有 Codespaces 访问权限才能使用此端点。

OAuth 应用令牌和个人访问令牌(经典)需要 codespacecodespace:secrets 范围才能使用此端点。

用于“获取已认证用户的密钥”的细粒度访问令牌

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

细粒度令牌必须具有以下权限集

  • “Codespaces 用户密钥”用户权限(读取)

用于“获取已认证用户的密钥”的参数

标头
名称、类型、描述
accept string

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

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

密钥的名称。

用于“获取已认证用户的密钥”的 HTTP 响应状态码

状态代码描述
200

OK

用于“获取已认证用户的密钥”的代码示例

请求示例

获取/user/codespaces/secrets/{secret_name}
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/user/codespaces/secrets/SECRET_NAME

响应

状态:200
{ "name": "CODESPACE_GH_SECRET", "created_at": "2019-08-10T14:59:22Z", "updated_at": "2020-01-10T14:59:22Z", "visibility": "selected", "selected_repositories_url": "https://api.github.com/user/codespaces/secrets/CODESPACE_GH_SECRET/repositories" }

创建或更新已认证用户的密钥

使用加密值创建或更新用户代码空间的开发环境密钥。使用 LibSodium 加密您的密钥。有关更多信息,请参阅“加密 REST API 的密钥”。

经过身份验证的用户必须具有 Codespaces 访问权限才能使用此端点。

OAuth 应用令牌和个人访问令牌(经典)需要 codespacecodespace:secrets 范围才能使用此端点。

用于“创建或更新已认证用户的密钥”的细粒度访问令牌

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

细粒度令牌必须具有以下权限集

  • “代码空间用户密钥”用户权限(写入)

用于“创建或更新已认证用户的密钥”的参数

标头
名称、类型、描述
accept string

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

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

密钥的名称。

主体参数
名称、类型、描述
encrypted_value 字符串

您的密钥的值,使用 LibSodium 使用从 获取已认证用户的公钥 端点检索的公钥加密。

key_id 字符串 必需

用于加密密钥的密钥的 ID。

selected_repository_ids 数组

可以访问用户密钥的存储库 ID 数组。您可以使用 列出用户密钥的选定存储库设置用户密钥的选定存储库从用户密钥中删除选定存储库 端点来管理选定存储库的列表。

用于“创建或更新已认证用户的密钥”的 HTTP 响应状态码

状态代码描述
201

成功创建密钥后的响应

204

成功更新密钥后的响应

404

资源未找到

422

验证失败,或端点被刷屏。

“为已认证用户创建或更新密钥”的代码示例

请求示例

put/user/codespaces/secrets/{secret_name}
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/user/codespaces/secrets/SECRET_NAME \ -d '{"encrypted_value":"c2VjcmV0","key_id":"012345678912345678","selected_repository_ids":["1234567","2345678"]}'

成功创建密钥后的响应

删除已认证用户的密钥

使用密钥名称从用户的 codespaces 中删除开发环境密钥。删除密钥将从所有被允许访问该密钥的 codespaces 中删除访问权限。

经过身份验证的用户必须具有 Codespaces 访问权限才能使用此端点。

OAuth 应用令牌和个人访问令牌(经典)需要 codespacecodespace:secrets 范围才能使用此端点。

“删除已认证用户的密钥”的细粒度访问令牌

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

细粒度令牌必须具有以下权限集

  • “代码空间用户密钥”用户权限(写入)

“删除已认证用户的密钥”的参数

标头
名称、类型、描述
accept string

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

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

密钥的名称。

“删除已认证用户的密钥”的 HTTP 响应状态码

状态代码描述
204

无内容

“删除已认证用户的密钥”的代码示例

请求示例

delete/user/codespaces/secrets/{secret_name}
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/user/codespaces/secrets/SECRET_NAME

响应

状态: 204

列出为用户密钥选择的存储库

列出已授予使用用户开发环境密钥的存储库。

经过身份验证的用户必须具有 Codespaces 访问权限才能使用此端点。

OAuth 应用令牌和个人访问令牌(经典)需要 codespacecodespace:secrets 范围才能使用此端点。

用于“列出为用户密钥选择的存储库”的细粒度访问令牌

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

细粒度令牌必须具有以下权限集

  • “Codespaces 用户密钥”用户权限(读取)

用于“列出为用户密钥选择的存储库”的参数

标头
名称、类型、描述
accept string

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

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

密钥的名称。

用于“列出为用户密钥选择的存储库”的 HTTP 响应状态代码

状态代码描述
200

OK

401

需要身份验证

403

禁止

404

资源未找到

500

内部错误

用于“列出为用户密钥选择的存储库”的代码示例

请求示例

get/user/codespaces/secrets/{secret_name}/repositories
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/user/codespaces/secrets/SECRET_NAME/repositories

响应

状态:200
{ "total_count": 1, "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": "[email protected]: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 }, "template_repository": { "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": "[email protected]: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", "organization": null, "language": null, "forks": 9, "forks_count": 9, "stargazers_count": 80, "watchers_count": 80, "watchers": 80, "size": 108, "default_branch": "master", "open_issues": 0, "open_issues_count": 0, "is_template": true, "license": { "key": "mit", "name": "MIT License", "url": "https://api.github.com/licenses/mit", "spdx_id": "MIT", "node_id": "MDc6TGljZW5zZW1pdA==", "html_url": "https://api.github.com/licenses/mit" }, "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 }, "temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O", "delete_branch_on_merge": 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==" }, "forks": 1, "open_issues": 1, "watchers": 1 } ] }

为用户密钥设置选定的存储库

选择将使用用户开发环境密钥的存储库。

经过身份验证的用户必须具有 Codespaces 访问权限才能使用此端点。

OAuth 应用令牌和个人访问令牌(经典)需要 codespacecodespace:secrets 范围才能使用此端点。

用于“设置为用户密钥选择的存储库”的细粒度访问令牌

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

细粒度令牌必须具有以下权限集

  • “代码空间用户密钥”用户权限(写入)

用于“设置为用户密钥选择的存储库”的参数

标头
名称、类型、描述
accept string

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

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

密钥的名称。

主体参数
名称、类型、描述
selected_repository_ids 整数数组 必需

一个存储库 ID 数组,codespace 可以访问其中的密钥。您可以使用 列出为用户密钥选择的存储库将选定的存储库添加到用户密钥从用户密钥中删除选定的存储库 端点来管理选定存储库的列表。

用于“设置为用户密钥选择的存储库”的 HTTP 响应状态代码

状态代码描述
204

将存储库添加到选定列表时,无内容

401

需要身份验证

403

禁止

404

资源未找到

500

内部错误

用于“设置为用户密钥选择的存储库”的代码示例

请求示例

put/user/codespaces/secrets/{secret_name}/repositories
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/user/codespaces/secrets/SECRET_NAME/repositories \ -d '{"selected_repository_ids":["1296269","1296280"]}'

将存储库添加到选定列表时,无内容

状态: 204

将选定的存储库添加到用户密钥

将存储库添加到用户开发环境密钥的选定存储库中。

经过身份验证的用户必须具有 Codespaces 访问权限才能使用此端点。

OAuth 应用令牌和个人访问令牌(经典)需要 codespacecodespace:secrets 范围才能使用此端点。

用于“将选定的存储库添加到用户密钥”的细粒度访问令牌

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

细粒度令牌必须具有以下权限集

  • "Codespaces 用户密钥" 用户权限 (写入)"元数据" 存储库权限 (读取)

用于“将选定的存储库添加到用户密钥”的参数

标头
名称、类型、描述
accept string

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

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

密钥的名称。

repository_id 整数 必填

将选定仓库添加到用户密钥的 HTTP 响应状态码

状态代码描述
204

当仓库被添加到选定列表时,返回无内容

401

需要身份验证

403

禁止

404

资源未找到

500

内部错误

将选定仓库添加到用户密钥的代码示例

请求示例

put/user/codespaces/secrets/{secret_name}/repositories/{repository_id}
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/user/codespaces/secrets/SECRET_NAME/repositories/REPOSITORY_ID

当仓库被添加到选定列表时,返回无内容

状态: 204

从用户密钥中删除选定仓库

从用户的开发环境密钥的选定仓库中删除一个仓库。

经过身份验证的用户必须具有 Codespaces 访问权限才能使用此端点。

OAuth 应用令牌和个人访问令牌(经典)需要 codespacecodespace:secrets 范围才能使用此端点。

从用户密钥中删除选定仓库的细粒度访问令牌

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

细粒度令牌必须具有以下权限集

  • "Codespaces 用户密钥" 用户权限 (写入)"元数据" 存储库权限 (读取)

从用户密钥中删除选定仓库的参数

标头
名称、类型、描述
accept string

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

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

密钥的名称。

repository_id 整数 必填

从用户密钥中删除选定仓库的 HTTP 响应状态码

状态代码描述
204

当仓库从选定列表中删除时,返回无内容

401

需要身份验证

403

禁止

404

资源未找到

500

内部错误

从用户密钥中删除选定仓库的代码示例

请求示例

delete/user/codespaces/secrets/{secret_name}/repositories/{repository_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/user/codespaces/secrets/SECRET_NAME/repositories/REPOSITORY_ID

当仓库从选定列表中删除时,返回无内容

状态: 204