gpg_keys
Creates, updates, deletes, gets or lists a gpg_keys resource.
Overview
| Name | gpg_keys |
| Type | Resource |
| Id | github.users.gpg_keys |
Fields
The following fields are returned by SELECT queries:
- get_gpg_key_for_authenticated_user
- list_gpg_keys_for_user
- list_gpg_keys_for_authenticated_user
Response
| Name | Datatype | Description |
|---|---|---|
id | integer (int64) | |
name | string | (example: Octocat's GPG Key) |
key_id | string | (example: 3262EFF25BA0D270) |
primary_key_id | integer | |
can_certify | boolean | |
can_encrypt_comms | boolean | |
can_encrypt_storage | boolean | |
can_sign | boolean | |
created_at | string (date-time) | (example: 2016-03-24T11:31:04-06:00) |
emails | array | |
expires_at | string (date-time) | |
public_key | string | (example: xsBNBFayYZ...) |
raw_key | string | |
revoked | boolean | |
subkeys | array |
Response
| Name | Datatype | Description |
|---|---|---|
id | integer (int64) | |
name | string | (example: Octocat's GPG Key) |
key_id | string | (example: 3262EFF25BA0D270) |
primary_key_id | integer | |
can_certify | boolean | |
can_encrypt_comms | boolean | |
can_encrypt_storage | boolean | |
can_sign | boolean | |
created_at | string (date-time) | (example: 2016-03-24T11:31:04-06:00) |
emails | array | |
expires_at | string (date-time) | |
public_key | string | (example: xsBNBFayYZ...) |
raw_key | string | |
revoked | boolean | |
subkeys | array |
Response
| Name | Datatype | Description |
|---|---|---|
id | integer (int64) | |
name | string | (example: Octocat's GPG Key) |
key_id | string | (example: 3262EFF25BA0D270) |
primary_key_id | integer | |
can_certify | boolean | |
can_encrypt_comms | boolean | |
can_encrypt_storage | boolean | |
can_sign | boolean | |
created_at | string (date-time) | (example: 2016-03-24T11:31:04-06:00) |
emails | array | |
expires_at | string (date-time) | |
public_key | string | (example: xsBNBFayYZ...) |
raw_key | string | |
revoked | boolean | |
subkeys | array |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_gpg_key_for_authenticated_user | select | gpg_key_id | View extended details for a single GPG key. OAuth app tokens and personal access tokens (classic) need the read:gpg_key scope to use this endpoint. | |
list_gpg_keys_for_user | select | username | per_page, page | Lists the GPG keys for a user. This information is accessible by anyone. |
list_gpg_keys_for_authenticated_user | select | per_page, page | Lists the current user's GPG keys. OAuth app tokens and personal access tokens (classic) need the read:gpg_key scope to use this endpoint. | |
create_gpg_key_for_authenticated_user | insert | armored_public_key | Adds a GPG key to the authenticated user's GitHub account. OAuth app tokens and personal access tokens (classic) need the write:gpg_key scope to use this endpoint. | |
delete_gpg_key_for_authenticated_user | delete | gpg_key_id | Removes a GPG key from the authenticated user's GitHub account. OAuth app tokens and personal access tokens (classic) need the admin:gpg_key scope to use this endpoint. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
gpg_key_id | integer | The unique identifier of the GPG key. |
username | string | The handle for the GitHub user account. |
page | integer | The page number of the results to fetch. For more information, see "Using pagination in the REST API." |
per_page | integer | The number of results per page (max 100). For more information, see "Using pagination in the REST API." |
SELECT examples
- get_gpg_key_for_authenticated_user
- list_gpg_keys_for_user
- list_gpg_keys_for_authenticated_user
View extended details for a single GPG key.
OAuth app tokens and personal access tokens (classic) need the read:gpg_key scope to use this endpoint.
SELECT
id,
name,
key_id,
primary_key_id,
can_certify,
can_encrypt_comms,
can_encrypt_storage,
can_sign,
created_at,
emails,
expires_at,
public_key,
raw_key,
revoked,
subkeys
FROM github.users.gpg_keys
WHERE gpg_key_id = '{{ gpg_key_id }}' -- required
;
Lists the GPG keys for a user. This information is accessible by anyone.
SELECT
id,
name,
key_id,
primary_key_id,
can_certify,
can_encrypt_comms,
can_encrypt_storage,
can_sign,
created_at,
emails,
expires_at,
public_key,
raw_key,
revoked,
subkeys
FROM github.users.gpg_keys
WHERE username = '{{ username }}' -- required
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
;
Lists the current user's GPG keys.
OAuth app tokens and personal access tokens (classic) need the read:gpg_key scope to use this endpoint.
SELECT
id,
name,
key_id,
primary_key_id,
can_certify,
can_encrypt_comms,
can_encrypt_storage,
can_sign,
created_at,
emails,
expires_at,
public_key,
raw_key,
revoked,
subkeys
FROM github.users.gpg_keys
WHERE per_page = '{{ per_page }}'
AND page = '{{ page }}'
;
INSERT examples
- create_gpg_key_for_authenticated_user
- Manifest
Adds a GPG key to the authenticated user's GitHub account.
OAuth app tokens and personal access tokens (classic) need the write:gpg_key scope to use this endpoint.
INSERT INTO github.users.gpg_keys (
name,
armored_public_key
)
SELECT
'{{ name }}',
'{{ armored_public_key }}' /* required */
RETURNING
id,
name,
key_id,
primary_key_id,
can_certify,
can_encrypt_comms,
can_encrypt_storage,
can_sign,
created_at,
emails,
expires_at,
public_key,
raw_key,
revoked,
subkeys
;
# Description fields are for documentation purposes
- name: gpg_keys
props:
- name: name
value: "{{ name }}"
description: |
A descriptive name for the new key.
- name: armored_public_key
value: "{{ armored_public_key }}"
description: |
A GPG key in ASCII-armored format.
DELETE examples
- delete_gpg_key_for_authenticated_user
Removes a GPG key from the authenticated user's GitHub account.
OAuth app tokens and personal access tokens (classic) need the admin:gpg_key scope to use this endpoint.
DELETE FROM github.users.gpg_keys
WHERE gpg_key_id = '{{ gpg_key_id }}' --required
;