Skip to main content
REST API теперь версия. Дополнительные сведения см. в разделе "О управлении версиями API".

Конечные точки REST API для секретов репозитория Codespaces

Используйте REST API для управления секретами для репозиториев, к которым пользователь имеет доступ в пространстве кода.

Кто эту функцию можно использовать?

Users with write access to a repository can manage Codespaces repository secrets.

Сведения о секретах репозитория Codespaces

Вы можете создавать, перечислять и удалять секреты (например, маркеры доступа для облачных служб) для репозиториев, к которым у пользователя есть доступ. Эти секреты становятся доступными для кодового пространства в среде выполнения. Дополнительные сведения см. в разделе Управление секретами конкретной учетной записи для GitHub Codespaces.

List repository secrets

Lists all development environment secrets available in a repository without revealing their encrypted values.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Подробные маркеры доступа для "List repository secrets

Эта конечная точка работает со следующими типами маркеров:

Маркер должен иметь следующий набор разрешений.:

  • codespaces_secrets:write

Параметры для "List repository secrets"

Заголовки
Имя., Тип, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя., Тип, Description
owner string Обязательное поле

The account owner of the repository. The name is not case sensitive.

repo string Обязательное поле

The name of the repository without the .git extension. The name is not case sensitive.

Параметры запроса
Имя., Тип, Description
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

По умолчанию.: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

По умолчанию.: 1

Коды состояния http-ответа для "List repository secrets"

Код состоянияОписание
200

OK

Примеры кода для "List repository secrets"

Пример запроса

get/repos/{owner}/{repo}/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/repos/OWNER/REPO/codespaces/secrets

Response

Status: 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" } ] }

Get a repository public key

Gets your public key, which you need to encrypt secrets. You need to encrypt a secret before you can create or update secrets.

Anyone with read access to the repository can use this endpoint.

If the repository is private, OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Подробные маркеры доступа для "Get a repository public key

Эта конечная точка работает со следующими типами маркеров:

Маркер должен иметь следующий набор разрешений.:

  • codespaces_secrets:write

Параметры для "Get a repository public key"

Заголовки
Имя., Тип, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя., Тип, Description
owner string Обязательное поле

The account owner of the repository. The name is not case sensitive.

repo string Обязательное поле

The name of the repository without the .git extension. The name is not case sensitive.

Коды состояния http-ответа для "Get a repository public key"

Код состоянияОписание
200

OK

Примеры кода для "Get a repository public key"

Пример запроса

get/repos/{owner}/{repo}/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/repos/OWNER/REPO/codespaces/secrets/public-key

Response

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

Get a repository secret

Gets a single repository development environment secret without revealing its encrypted value.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Подробные маркеры доступа для "Get a repository secret

Эта конечная точка работает со следующими типами маркеров:

Маркер должен иметь следующий набор разрешений.:

  • codespaces_secrets:write

Параметры для "Get a repository secret"

Заголовки
Имя., Тип, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя., Тип, Description
owner string Обязательное поле

The account owner of the repository. The name is not case sensitive.

repo string Обязательное поле

The name of the repository without the .git extension. The name is not case sensitive.

secret_name string Обязательное поле

The name of the secret.

Коды состояния http-ответа для "Get a repository secret"

Код состоянияОписание
200

OK

Примеры кода для "Get a repository secret"

Пример запроса

get/repos/{owner}/{repo}/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/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME

Response

Status: 200
{ "name": "GH_TOKEN", "created_at": "2019-08-10T14:59:22Z", "updated_at": "2020-01-10T14:59:22Z", "visibility": "all" }

Create or update a repository secret

Creates or updates a repository development environment secret with an encrypted value. Encrypt your secret using LibSodium. For more information, see "Encrypting secrets for the REST API."

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Подробные маркеры доступа для "Create or update a repository secret

Эта конечная точка работает со следующими типами маркеров:

Маркер должен иметь следующий набор разрешений.:

  • codespaces_secrets:write

Параметры для "Create or update a repository secret"

Заголовки
Имя., Тип, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя., Тип, Description
owner string Обязательное поле

The account owner of the repository. The name is not case sensitive.

repo string Обязательное поле

The name of the repository without the .git extension. The name is not case sensitive.

secret_name string Обязательное поле

The name of the secret.

Параметры запроса
Имя., Тип, Description
encrypted_value string

Value for your secret, encrypted with LibSodium using the public key retrieved from the Get a repository public key endpoint.

key_id string

ID of the key you used to encrypt the secret.

Коды состояния http-ответа для "Create or update a repository secret"

Код состоянияОписание
201

Response when creating a secret

204

Response when updating a secret

Примеры кода для "Create or update a repository secret"

Примеры запросов

put/repos/{owner}/{repo}/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/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME \ -d '{"encrypted_value":"c2VjcmV0","key_id":"012345678912345678"}'

Response when creating a secret

Delete a repository secret

Deletes a development environment secret in a repository using the secret name.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Подробные маркеры доступа для "Delete a repository secret

Эта конечная точка работает со следующими типами маркеров:

Маркер должен иметь следующий набор разрешений.:

  • codespaces_secrets:write

Параметры для "Delete a repository secret"

Заголовки
Имя., Тип, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя., Тип, Description
owner string Обязательное поле

The account owner of the repository. The name is not case sensitive.

repo string Обязательное поле

The name of the repository without the .git extension. The name is not case sensitive.

secret_name string Обязательное поле

The name of the secret.

Коды состояния http-ответа для "Delete a repository secret"

Код состоянияОписание
204

No Content

Примеры кода для "Delete a repository secret"

Пример запроса

delete/repos/{owner}/{repo}/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/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME

Response

Status: 204