|
| 1 | +--- |
| 2 | +name: Create a scoped access token |
| 3 | +example: octokit.apps.scopeToken({ client_id }) |
| 4 | +route: POST /applications/{client_id}/token/scoped |
| 5 | +scope: apps |
| 6 | +type: API method |
| 7 | +--- |
| 8 | + |
| 9 | +# Create a scoped access token |
| 10 | + |
| 11 | +Exchanges a non-repository scoped user-to-server OAuth access token for a repository scoped user-to-server OAuth access token. You can specify which repositories the token can access and which permissions are granted to the token. You must use [Basic Authentication](https://docs.github.com/rest/overview/other-authentication-methods#basic-authentication) when accessing this endpoint, using the OAuth application's `client_id` and `client_secret` as the username and password. Invalid tokens will return `404 NOT FOUND`. |
| 12 | + |
| 13 | +```js |
| 14 | +octokit.apps.scopeToken({ |
| 15 | + client_id, |
| 16 | +}); |
| 17 | +``` |
| 18 | + |
| 19 | +## Parameters |
| 20 | + |
| 21 | +<table> |
| 22 | + <thead> |
| 23 | + <tr> |
| 24 | + <th>name</th> |
| 25 | + <th>required</th> |
| 26 | + <th>description</th> |
| 27 | + </tr> |
| 28 | + </thead> |
| 29 | + <tbody> |
| 30 | + <tr><td>client_id</td><td>yes</td><td> |
| 31 | + |
| 32 | +The client ID of your GitHub app. |
| 33 | + |
| 34 | +</td></tr> |
| 35 | +<tr><td>access_token</td><td>no</td><td> |
| 36 | + |
| 37 | +**Required.** The OAuth access token used to authenticate to the GitHub API. |
| 38 | + |
| 39 | +</td></tr> |
| 40 | +<tr><td>target</td><td>no</td><td> |
| 41 | + |
| 42 | +The name of the user or organization to scope the user-to-server access token to. **Required** unless `target_id` is specified. |
| 43 | + |
| 44 | +</td></tr> |
| 45 | +<tr><td>target_id</td><td>no</td><td> |
| 46 | + |
| 47 | +The ID of the user or organization to scope the user-to-server access token to. **Required** unless `target` is specified. |
| 48 | + |
| 49 | +</td></tr> |
| 50 | +<tr><td>repositories</td><td>no</td><td> |
| 51 | + |
| 52 | +The list of repository IDs to scope the user-to-server access token to. `repositories` may not be specified if `repository_ids` is specified. |
| 53 | + |
| 54 | +</td></tr> |
| 55 | +<tr><td>repository_ids</td><td>no</td><td> |
| 56 | + |
| 57 | +The list of repository names to scope the user-to-server access token to. `repository_ids` may not be specified if `repositories` is specified. |
| 58 | + |
| 59 | +</td></tr> |
| 60 | +<tr><td>permissions</td><td>no</td><td> |
| 61 | + |
| 62 | +The permissions granted to the user-to-server access token. |
| 63 | + |
| 64 | +</td></tr> |
| 65 | +<tr><td>permissions.actions</td><td>no</td><td> |
| 66 | + |
| 67 | +The level of permission to grant the access token for GitHub Actions workflows, workflow runs, and artifacts. Can be one of: `read` or `write`. |
| 68 | + |
| 69 | +</td></tr> |
| 70 | +<tr><td>permissions.administration</td><td>no</td><td> |
| 71 | + |
| 72 | +The level of permission to grant the access token for repository creation, deletion, settings, teams, and collaborators creation. Can be one of: `read` or `write`. |
| 73 | + |
| 74 | +</td></tr> |
| 75 | +<tr><td>permissions.checks</td><td>no</td><td> |
| 76 | + |
| 77 | +The level of permission to grant the access token for checks on code. Can be one of: `read` or `write`. |
| 78 | + |
| 79 | +</td></tr> |
| 80 | +<tr><td>permissions.content_references</td><td>no</td><td> |
| 81 | + |
| 82 | +The level of permission to grant the access token for notification of content references and creation content attachments. Can be one of: `read` or `write`. |
| 83 | + |
| 84 | +</td></tr> |
| 85 | +<tr><td>permissions.contents</td><td>no</td><td> |
| 86 | + |
| 87 | +The level of permission to grant the access token for repository contents, commits, branches, downloads, releases, and merges. Can be one of: `read` or `write`. |
| 88 | + |
| 89 | +</td></tr> |
| 90 | +<tr><td>permissions.deployments</td><td>no</td><td> |
| 91 | + |
| 92 | +The level of permission to grant the access token for deployments and deployment statuses. Can be one of: `read` or `write`. |
| 93 | + |
| 94 | +</td></tr> |
| 95 | +<tr><td>permissions.environments</td><td>no</td><td> |
| 96 | + |
| 97 | +The level of permission to grant the access token for managing repository environments. Can be one of: `read` or `write`. |
| 98 | + |
| 99 | +</td></tr> |
| 100 | +<tr><td>permissions.issues</td><td>no</td><td> |
| 101 | + |
| 102 | +The level of permission to grant the access token for issues and related comments, assignees, labels, and milestones. Can be one of: `read` or `write`. |
| 103 | + |
| 104 | +</td></tr> |
| 105 | +<tr><td>permissions.metadata</td><td>no</td><td> |
| 106 | + |
| 107 | +The level of permission to grant the access token to search repositories, list collaborators, and access repository metadata. Can be one of: `read` or `write`. |
| 108 | + |
| 109 | +</td></tr> |
| 110 | +<tr><td>permissions.packages</td><td>no</td><td> |
| 111 | + |
| 112 | +The level of permission to grant the access token for packages published to GitHub Packages. Can be one of: `read` or `write`. |
| 113 | + |
| 114 | +</td></tr> |
| 115 | +<tr><td>permissions.pages</td><td>no</td><td> |
| 116 | + |
| 117 | +The level of permission to grant the access token to retrieve Pages statuses, configuration, and builds, as well as create new builds. Can be one of: `read` or `write`. |
| 118 | + |
| 119 | +</td></tr> |
| 120 | +<tr><td>permissions.pull_requests</td><td>no</td><td> |
| 121 | + |
| 122 | +The level of permission to grant the access token for pull requests and related comments, assignees, labels, milestones, and merges. Can be one of: `read` or `write`. |
| 123 | + |
| 124 | +</td></tr> |
| 125 | +<tr><td>permissions.repository_hooks</td><td>no</td><td> |
| 126 | + |
| 127 | +The level of permission to grant the access token to manage the post-receive hooks for a repository. Can be one of: `read` or `write`. |
| 128 | + |
| 129 | +</td></tr> |
| 130 | +<tr><td>permissions.repository_projects</td><td>no</td><td> |
| 131 | + |
| 132 | +The level of permission to grant the access token to manage repository projects, columns, and cards. Can be one of: `read`, `write`, or `admin`. |
| 133 | + |
| 134 | +</td></tr> |
| 135 | +<tr><td>permissions.secret_scanning_alerts</td><td>no</td><td> |
| 136 | + |
| 137 | +The level of permission to grant the access token to view and manage secret scanning alerts. Can be one of: `read` or `write`. |
| 138 | + |
| 139 | +</td></tr> |
| 140 | +<tr><td>permissions.secrets</td><td>no</td><td> |
| 141 | + |
| 142 | +The level of permission to grant the access token to manage repository secrets. Can be one of: `read` or `write`. |
| 143 | + |
| 144 | +</td></tr> |
| 145 | +<tr><td>permissions.security_events</td><td>no</td><td> |
| 146 | + |
| 147 | +The level of permission to grant the access token to view and manage security events like code scanning alerts. Can be one of: `read` or `write`. |
| 148 | + |
| 149 | +</td></tr> |
| 150 | +<tr><td>permissions.single_file</td><td>no</td><td> |
| 151 | + |
| 152 | +The level of permission to grant the access token to manage just a single file. Can be one of: `read` or `write`. |
| 153 | + |
| 154 | +</td></tr> |
| 155 | +<tr><td>permissions.statuses</td><td>no</td><td> |
| 156 | + |
| 157 | +The level of permission to grant the access token for commit statuses. Can be one of: `read` or `write`. |
| 158 | + |
| 159 | +</td></tr> |
| 160 | +<tr><td>permissions.vulnerability_alerts</td><td>no</td><td> |
| 161 | + |
| 162 | +The level of permission to grant the access token to retrieve Dependabot alerts. Can be one of: `read`. |
| 163 | + |
| 164 | +</td></tr> |
| 165 | +<tr><td>permissions.workflows</td><td>no</td><td> |
| 166 | + |
| 167 | +The level of permission to grant the access token to update GitHub Actions workflow files. Can be one of: `write`. |
| 168 | + |
| 169 | +</td></tr> |
| 170 | +<tr><td>permissions.members</td><td>no</td><td> |
| 171 | + |
| 172 | +The level of permission to grant the access token for organization teams and members. Can be one of: `read` or `write`. |
| 173 | + |
| 174 | +</td></tr> |
| 175 | +<tr><td>permissions.organization_administration</td><td>no</td><td> |
| 176 | + |
| 177 | +The level of permission to grant the access token to manage access to an organization. Can be one of: `read` or `write`. |
| 178 | + |
| 179 | +</td></tr> |
| 180 | +<tr><td>permissions.organization_hooks</td><td>no</td><td> |
| 181 | + |
| 182 | +The level of permission to grant the access token to manage the post-receive hooks for an organization. Can be one of: `read` or `write`. |
| 183 | + |
| 184 | +</td></tr> |
| 185 | +<tr><td>permissions.organization_plan</td><td>no</td><td> |
| 186 | + |
| 187 | +The level of permission to grant the access token for viewing an organization's plan. Can be one of: `read`. |
| 188 | + |
| 189 | +</td></tr> |
| 190 | +<tr><td>permissions.organization_projects</td><td>no</td><td> |
| 191 | + |
| 192 | +The level of permission to grant the access token to manage organization projects, columns, and cards. Can be one of: `read`, `write`, or `admin`. |
| 193 | + |
| 194 | +</td></tr> |
| 195 | +<tr><td>permissions.organization_secrets</td><td>no</td><td> |
| 196 | + |
| 197 | +The level of permission to grant the access token to manage organization secrets. Can be one of: `read` or `write`. |
| 198 | + |
| 199 | +</td></tr> |
| 200 | +<tr><td>permissions.organization_self_hosted_runners</td><td>no</td><td> |
| 201 | + |
| 202 | +The level of permission to grant the access token to view and manage GitHub Actions self-hosted runners available to an organization. Can be one of: `read` or `write`. |
| 203 | + |
| 204 | +</td></tr> |
| 205 | +<tr><td>permissions.organization_user_blocking</td><td>no</td><td> |
| 206 | + |
| 207 | +The level of permission to grant the access token to view and manage users blocked by the organization. Can be one of: `read` or `write`. |
| 208 | + |
| 209 | +</td></tr> |
| 210 | +<tr><td>permissions.team_discussions</td><td>no</td><td> |
| 211 | + |
| 212 | +The level of permission to grant the access token to manage team discussions and related comments. Can be one of: `read` or `write`. |
| 213 | + |
| 214 | +</td></tr> |
| 215 | + </tbody> |
| 216 | +</table> |
| 217 | + |
| 218 | +See also: [GitHub Developer Guide documentation](https://docs.github.com/rest/reference/apps#create-a-scoped-access-token). |
0 commit comments