Skip to main content
Frecuentemente publicamos actualizaciones de nuestra documentación. Es posible que la traducción de esta página esté en curso. Para conocer la información más actual, visita la documentación en inglés. Si existe un problema con las traducciones en esta página, por favor infórmanos.

Esta versión de GitHub Enterprise se discontinuó el 2022-06-03. No se realizarán lanzamientos de patch, ni siquiera para problemas de seguridad críticos. Para obtener un mejor desempeño, más seguridad y nuevas características, actualiza a la última versión de GitHub Enterprise. Para obtener ayuda con la actualización, contacta al soporte de GitHub Enterprise.

GPG Keys

About the User GPG keys API

Los datos que se devuelven en el campo de respuesta de public_key no son una llave con formato de GPG. Cuando un usuario carga una llave GPG, se interpreta y la llave pública criptográfica se extrae y se almacena. Esta llave criptográfica es lo que devuelven las API en esta página. Esta llave no es apta para utilizarse directamente con programas como GPG.

Many of the resources on this API provide a shortcut for getting information about the currently authenticated user. Si una URL de solicitud no incluye un parámetro de {username}, entonces la respuesta será para el usuario que inició sesión (y debes pasar la información de autenticación con tu solicitud). La información privada adicional, tal como si un usuario tiene habilitada la autenticación bifactorial, se incluye cuando se está autenticado con la autenticación básica o a través de OAuth, con el alcance de user.

List GPG keys for the authenticated user

Lists the current user's GPG keys. Requires that you are authenticated via Basic Auth or via OAuth with at least read:gpg_key scope.

Parámetros

Encabezados
Nombre, Tipo, Descripción
acceptstring

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

Parámetros de consulta
Nombre, Tipo, Descripción
per_pageinteger

The number of results per page (max 100).

Predeterminado: 30

pageinteger

Page number of the results to fetch.

Predeterminado: 1

Códigos de estado de respuesta HTTP

Código de estadoDescripción
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

Ejemplos de código

get/user/gpg_keys
curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/user/gpg_keys

Response

Status: 200
[ { "id": 3, "primary_key_id": 2, "key_id": "3262EFF25BA0D270", "public_key": "xsBNBFayYZ...", "emails": [ { "email": "octocat@users.noreply.github.com", "verified": true } ], "subkeys": [ { "id": 4, "primary_key_id": 3, "key_id": "4A595D4C72EE49C7", "public_key": "zsBNBFayYZ...", "emails": [], "subkeys": [], "can_sign": false, "can_encrypt_comms": true, "can_encrypt_storage": true, "can_certify": false, "created_at": "2016-03-24T11:31:04-06:00", "expires_at": "2016-03-24T11:31:04-07:00" } ], "can_sign": true, "can_encrypt_comms": false, "can_encrypt_storage": false, "can_certify": true, "created_at": "2016-03-24T11:31:04-06:00", "expires_at": "2016-03-24T11:31:04-07:00", "raw_key": "string" } ]

Create a GPG key for the authenticated user

Adds a GPG key to the authenticated user's GitHub account. Requires that you are authenticated via Basic Auth, or OAuth with at least write:gpg_key scope.

Parámetros

Encabezados
Nombre, Tipo, Descripción
acceptstring

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

Parámetros de cuerpo
Nombre, Tipo, Descripción
armored_public_keystringRequerido

A GPG key in ASCII-armored format.

Códigos de estado de respuesta HTTP

Código de estadoDescripción
201

Created

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

422

Validation failed

Ejemplos de código

post/user/gpg_keys
curl \ -X POST \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/user/gpg_keys

Response

Status: 201
{ "id": 3, "primary_key_id": 2, "key_id": "3262EFF25BA0D270", "public_key": "xsBNBFayYZ...", "emails": [ { "email": "octocat@users.noreply.github.com", "verified": true } ], "subkeys": [ { "id": 4, "primary_key_id": 3, "key_id": "4A595D4C72EE49C7", "public_key": "zsBNBFayYZ...", "emails": [], "subkeys": [], "can_sign": false, "can_encrypt_comms": true, "can_encrypt_storage": true, "can_certify": false, "created_at": "2016-03-24T11:31:04-06:00", "expires_at": "2016-03-24T11:31:04-07:00" } ], "can_sign": true, "can_encrypt_comms": false, "can_encrypt_storage": false, "can_certify": true, "created_at": "2016-03-24T11:31:04-06:00", "expires_at": "2016-03-24T11:31:04-07:00", "raw_key": "\"-----BEGIN PGP PUBLIC KEY BLOCK-----\\nVersion: Gnu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puMB2RsGK8GbNP+4SlOlAiPf5SMhS7nZNkNDgQQ\\naZ3HFpgrFmFwmE10BKT4iQtoxELLM57z0qGOAfTsEjWFQa4sF+6IHAQR/ptkdkkI\\nBUEXiMnAwVwBysLIJiLO8qdjB6qp52QkT074JVrwywT/P+DkMfC2k4r/AfEbf6eF\\ndmPDuPk6KD87+hJZsSa5MaMUBQVvRO/mgEkhJRITVu58eWGaBOcQJ8gqurhCqM5P\\nDfUA4TJ7wiqM6sS764vV1rOioTTXkszzhClQqET7hPVnVQjenYgv0EZHNyQH/1f1\\n/CYqvV1vFjM9vJjMbxXsATCkZe6wvBVKD8vLsJAr8N+onKQz+4OPc3kmKq7aESu3\\nCi/iuie5KKVwnuNhr9AzT61vEkKxwHcVFEvHB77F6ZAAInhRvjzmQbD2dlPLLQCC\\nqDj71ODSSAPTEmUy6969bgD9PfWei7kNkBIx7s3eBv8yzytSc2EcuUgopqFazquw\\nFs1+tqGHjBvQfTo6bqbJjp/9Ci2pvde3ElV2rAgUlb3lqXyXjRDqrXosh5GcRPQj\\nK8Nhj1BNhnrCVskE4BP0LYbOHuzgm86uXwGCFsY+w2VOsSm16Jx5GHyG5S5WU3+D\\nIts/HFYRLiFgDLmTlxo=\\n=+OzK\\n-----END PGP PUBLIC KEY BLOCK-----\"" }

Get a GPG key for the authenticated user

View extended details for a single GPG key. Requires that you are authenticated via Basic Auth or via OAuth with at least read:gpg_key scope.

Parámetros

Encabezados
Nombre, Tipo, Descripción
acceptstring

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

Parámetros de ruta
Nombre, Tipo, Descripción
gpg_key_idintegerRequerido

The unique identifier of the GPG key.

Códigos de estado de respuesta HTTP

Código de estadoDescripción
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

Ejemplos de código

get/user/gpg_keys/{gpg_key_id}
curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/user/gpg_keys/GPG_KEY_ID

Response

Status: 200
{ "id": 3, "primary_key_id": 2, "key_id": "3262EFF25BA0D270", "public_key": "xsBNBFayYZ...", "emails": [ { "email": "octocat@users.noreply.github.com", "verified": true } ], "subkeys": [ { "id": 4, "primary_key_id": 3, "key_id": "4A595D4C72EE49C7", "public_key": "zsBNBFayYZ...", "emails": [], "subkeys": [], "can_sign": false, "can_encrypt_comms": true, "can_encrypt_storage": true, "can_certify": false, "created_at": "2016-03-24T11:31:04-06:00", "expires_at": "2016-03-24T11:31:04-07:00" } ], "can_sign": true, "can_encrypt_comms": false, "can_encrypt_storage": false, "can_certify": true, "created_at": "2016-03-24T11:31:04-06:00", "expires_at": "2016-03-24T11:31:04-07:00", "raw_key": "\"-----BEGIN PGP PUBLIC KEY BLOCK-----\\nVersion: GnuPG v2\\n\\nmQENBFayYZ0BCAC4hScoJXXpyR+MXGcrBxElqw3FzCVvkViuyeko+Jp76QJhg8kr\\nucRTxbnOoHfda/FmilEa/wxf9ch5/PSrrL26FxEoPHhJolp8fnIDLQeITn94NYdB\\nZtnnEKslpPrG97qSUWIchvyqCPtvOb8+8fWvGx9K/ZWcEEdh1X8+WFR2jMENMeoX\\nwxHWQoPnS7LpX/85/M7VUcJxvDVfv+eHsnQupmE5bGarKNih0oMe3LbdN3qA5PTz\\nSCm6Iudar1VsQ+xTz08ymL7t4pnEtLguQ7EyatFHCjxNblv5RzxoL0tDgN3HqoDz\\nc7TEA+q4RtDQl9amcvQ95emnXmZ974u7UkYdABEBAAG0HlNvbWUgVXNlciA8c29t\\nZXVzZXJAZ21haWwuY29tPokBOAQTAQIAIgUCVrJhnQIbAwYLCQgHAwIGFQgCCQoL\\nBBYCAwECHgECF4AACgkQMmLv8lug0nAViQgArWjI55+7p48URr2z9Jvak+yrBTx1\\nzkufltQAnHTJkq+Kl9dySSmTnOop8o3rE4++IOpYV5Y36PkKf9EZMk4n1RQiDPKE\\nAFtRVTkRaoWzOir9KQXJPfhKrl01j/QzY+utfiMvUoBJZ9ybq8Pa885SljW9lb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Tlxo=\\n=+OzK\\n-----END PGP PUBLIC KEY BLOCK-----\"" }

Delete a GPG key for the authenticated user

Removes a GPG key from the authenticated user's GitHub account. Requires that you are authenticated via Basic Auth or via OAuth with at least admin:gpg_key scope.

Parámetros

Encabezados
Nombre, Tipo, Descripción
acceptstring

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

Parámetros de ruta
Nombre, Tipo, Descripción
gpg_key_idintegerRequerido

The unique identifier of the GPG key.

Códigos de estado de respuesta HTTP

Código de estadoDescripción
204

No Content

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

422

Validation failed

Ejemplos de código

delete/user/gpg_keys/{gpg_key_id}
curl \ -X DELETE \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/user/gpg_keys/GPG_KEY_ID

Response

Status: 204

List GPG keys for a user

Funciona con GitHub Apps

Lists the GPG keys for a user. This information is accessible by anyone.

Parámetros

Encabezados
Nombre, Tipo, Descripción
acceptstring

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

Parámetros de ruta
Nombre, Tipo, Descripción
usernamestringRequerido

The handle for the GitHub user account.

Parámetros de consulta
Nombre, Tipo, Descripción
per_pageinteger

The number of results per page (max 100).

Predeterminado: 30

pageinteger

Page number of the results to fetch.

Predeterminado: 1

Códigos de estado de respuesta HTTP

Código de estadoDescripción
200

OK

Ejemplos de código

get/users/{username}/gpg_keys
curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/users/USERNAME/gpg_keys

Response

Status: 200
[ { "id": 3, "primary_key_id": 2, "key_id": "3262EFF25BA0D270", "public_key": "xsBNBFayYZ...", "emails": [ { "email": "octocat@users.noreply.github.com", "verified": true } ], "subkeys": [ { "id": 4, "primary_key_id": 3, "key_id": "4A595D4C72EE49C7", "public_key": "zsBNBFayYZ...", "emails": [], "subkeys": [], "can_sign": false, "can_encrypt_comms": true, "can_encrypt_storage": true, "can_certify": false, "created_at": "2016-03-24T11:31:04-06:00", "expires_at": "2016-03-24T11:31:04-07:00" } ], "can_sign": true, "can_encrypt_comms": false, "can_encrypt_storage": false, "can_certify": true, "created_at": "2016-03-24T11:31:04-06:00", "expires_at": "2016-03-24T11:31:04-07:00", "raw_key": "string" } ]