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

Codespaces 用户密钥的 REST API 端点

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

关于 Codespaces 用户密钥

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

列出已认证用户的密钥

列出用户 codespace 可用的所有开发环境密钥,而不会泄露其加密值。

已认证用户必须具有 Codespaces 访问权限才能使用此端点。

OAuth 应用令牌和个人访问令牌(传统)需要 `codespace` 或 `codespace:secrets` 作用域才能使用此端点。

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

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

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

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

“列出已认证用户的密钥”的参数

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

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

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

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

默认值: 30

page 整数

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

默认值: 1

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

状态码描述
200

成功

“列出已认证用户的密钥”的代码示例

请求示例

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 应用令牌和个人访问令牌(传统)需要 `codespace` 或 `codespace:secrets` 作用域才能使用此端点。

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

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

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

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

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

状态码描述
200

成功

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

请求示例

get/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" }

获取已认证用户的密钥

获取用户 codespace 可用的开发环境密钥,而不会泄露其加密值。

已认证用户必须具有 Codespaces 访问权限才能使用此端点。

OAuth 应用令牌和个人访问令牌(传统)需要 `codespace` 或 `codespace:secrets` 作用域才能使用此端点。

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

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

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

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

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

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

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

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

密钥的名称。

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

状态码描述
200

成功

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

请求示例

get/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" }

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

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

已认证用户必须具有 Codespaces 访问权限才能使用此端点。

OAuth 应用令牌和个人访问令牌(传统)需要 `codespace` 或 `codespace:secrets` 作用域才能使用此端点。

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

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

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

  • “Codespaces 用户密钥”用户权限(写入)

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

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

建议设置为 `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 应用令牌和个人访问令牌(传统)需要 `codespace` 或 `codespace:secrets` 作用域才能使用此端点。

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

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

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

  • “Codespaces 用户密钥”用户权限(写入)

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

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

建议设置为 `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 应用令牌和个人访问令牌(传统)需要 `codespace` 或 `codespace:secrets` 作用域才能使用此端点。

"列出用户密钥的已选仓库" 的细粒度访问令牌

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

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

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

"列出用户密钥的已选仓库" 的参数

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

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

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

密钥的名称。

"列出用户密钥的已选仓库" 的 HTTP 响应状态码

状态码描述
200

成功

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 应用令牌和个人访问令牌(传统)需要 `codespace` 或 `codespace:secrets` 作用域才能使用此端点。

“为用户密钥设置选定的代码库”的细粒度访问令牌

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

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

  • “Codespaces 用户密钥”用户权限(写入)

“为用户密钥设置选定的代码库”的参数

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

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

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

密钥的名称。

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

代码空间可以访问密钥的代码库 ID 数组。您可以使用列出用户密钥的选定代码库向用户密钥添加选定代码库从用户密钥中删除选定代码库端点来管理选定代码库的列表。

“为用户密钥设置选定的代码库”的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 应用令牌和个人访问令牌(传统)需要 `codespace` 或 `codespace:secrets` 作用域才能使用此端点。

“向用户密钥添加选定的代码库”的细粒度访问令牌

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

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

  • “代码空间用户密钥”用户权限(写入)“元数据”代码库权限(读取)

“向用户密钥添加选定的代码库”的参数

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

建议设置为 `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 应用令牌和个人访问令牌(传统)需要 `codespace` 或 `codespace:secrets` 作用域才能使用此端点。

“从用户密钥中删除选定的代码库”的细粒度访问令牌

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

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

  • “代码空间用户密钥”用户权限(写入)“元数据”代码库权限(读取)

“从用户密钥中删除选定的代码库”的参数

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

建议设置为 `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