pat_grants
Creates, updates, deletes, gets or lists a pat_grants resource.
Overview
| Name | pat_grants |
| Type | Resource |
| Id | github.orgs.pat_grants |
Fields
The following fields are returned by SELECT queries:
- list_pat_grants
Response
| Name | Datatype | Description |
|---|---|---|
id | integer | Unique identifier of the fine-grained personal access token grant. The pat_id used to get details about an approved fine-grained personal access token. |
token_id | integer | Unique identifier of the user's token. This field can also be found in audit log events and the organization's settings for their PAT grants. |
token_name | string | The name given to the user's token. This field can also be found in an organization's settings page for Active Tokens. |
access_granted_at | string | Date and time when the fine-grained personal access token was approved to access the organization. |
owner | object | A GitHub user. (title: Simple User) |
permissions | object | Permissions requested, categorized by type of permission. |
repositories_url | string | URL to the list of repositories the fine-grained personal access token can access. Only follow when repository_selection is subset. |
repository_selection | string | Type of repository selection requested. (none, all, subset) |
token_expired | boolean | Whether the associated fine-grained personal access token has expired. |
token_expires_at | string | Date and time when the associated fine-grained personal access token expires. |
token_last_used_at | string | Date and time when the associated fine-grained personal access token was last used for authentication. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list_pat_grants | select | org | per_page, page, sort, direction, owner, repository, permission, last_used_before, last_used_after, token_id | Lists approved fine-grained personal access tokens owned by organization members that can access organization resources. Only GitHub Apps can use this endpoint. |
update_pat_accesses | exec | org, action, pat_ids | Updates the access organization members have to organization resources via fine-grained personal access tokens. Limited to revoking a token's existing access. Only GitHub Apps can use this endpoint. | |
update_pat_access | exec | org, pat_id, action | Updates the access an organization member has to organization resources via a fine-grained personal access token. Limited to revoking the token's existing access. Limited to revoking a token's existing access. Only GitHub Apps can 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 |
|---|---|---|
org | string | The organization name. The name is not case sensitive. |
pat_id | integer | The unique identifier of the fine-grained personal access token. |
direction | string | The direction to sort the results by. |
last_used_after | string (date-time) | Only show fine-grained personal access tokens used after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. |
last_used_before | string (date-time) | Only show fine-grained personal access tokens used before the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. |
owner | array | A list of owner usernames to use to filter the results. |
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." |
permission | string | The permission to use to filter the results. |
repository | string | The name of the repository to use to filter the results. |
sort | string | The property by which to sort the results. |
token_id | array | The ID of the token |
SELECT examples
- list_pat_grants
Lists approved fine-grained personal access tokens owned by organization members that can access organization resources.
Only GitHub Apps can use this endpoint.
SELECT
id,
token_id,
token_name,
access_granted_at,
owner,
permissions,
repositories_url,
repository_selection,
token_expired,
token_expires_at,
token_last_used_at
FROM github.orgs.pat_grants
WHERE org = '{{ org }}' -- required
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
AND sort = '{{ sort }}'
AND direction = '{{ direction }}'
AND owner = '{{ owner }}'
AND repository = '{{ repository }}'
AND permission = '{{ permission }}'
AND last_used_before = '{{ last_used_before }}'
AND last_used_after = '{{ last_used_after }}'
AND token_id = '{{ token_id }}'
;
Lifecycle Methods
- update_pat_accesses
- update_pat_access
Updates the access organization members have to organization resources via fine-grained personal access tokens. Limited to revoking a token's existing access.
Only GitHub Apps can use this endpoint.
EXEC github.orgs.pat_grants.update_pat_accesses
@org='{{ org }}' --required
@@json=
'{
"action": "{{ action }}",
"pat_ids": "{{ pat_ids }}"
}'
;
Updates the access an organization member has to organization resources via a fine-grained personal access token. Limited to revoking the token's existing access. Limited to revoking a token's existing access.
Only GitHub Apps can use this endpoint.
EXEC github.orgs.pat_grants.update_pat_access
@org='{{ org }}' --required,
@pat_id='{{ pat_id }}' --required
@@json=
'{
"action": "{{ action }}"
}'
;