Get-or-create an authorization for a specific app
Deprecated**Deprecation Notice:** GitHub Enterprise Server will discontinue the [OAuth Authorizations API](https://docs.github.com/[email protected]/rest/reference/oauth-authorizations/), which is used by integrations to create personal access tokens and OAuth tokens, and you must now create these tokens using our [web application flow](https://docs.github.com/[email protected]/developers/apps/authorizing-oauth-apps#web-application-flow). The [OAuth Authorizations API](https://docs.github.com/[email protected]/rest/reference/oauth-authorizations) will be removed on November, 13, 2020. For more information, including scheduled brownouts, see the [blog post](https://developer.github.com/changes/2020-02-14-deprecating-oauth-auth-endpoint/). **Warning:** Apps must use the [web application flow](https://docs.github.com/[email protected]/apps/building-oauth-apps/authorizing-oauth-apps/#web-application-flow) to obtain OAuth tokens that work with GitHub Enterprise Server SAML organizations. OAuth tokens created using the Authorizations API will be unable to access GitHub Enterprise Server SAML organizations. For more information, see the [blog post](https://developer.github.com/changes/2019-11-05-deprecated-passwords-and-authorizations-api). Creates a new authorization for the specified OAuth application, only if an authorization for that application doesn't already exist for the user. The URL includes the 20 character client ID for the OAuth app that is requesting the token. It returns the user's existing authorization for the application if one is present. Otherwise, it creates and returns a new one. If you have two-factor authentication setup, Basic Authentication for this endpoint requires that you use a one-time password (OTP) and your username and password instead of tokens. For more information, see "[Working with two-factor authentication](https://docs.github.com/[email protected]/rest/overview/other-authentication-methods#working-with-two-factor-authentication)." **Deprecation Notice:** GitHub Enterprise Server will discontinue the [OAuth Authorizations API](https://docs.github.com/[email protected]/rest/reference/oauth-authorizations/), which is used by integrations to create personal access tokens and OAuth tokens, and you must now create these tokens using our [web application flow](https://docs.github.com/[email protected]/developers/apps/authorizing-oauth-apps#web-application-flow). The [OAuth Authorizations API](https://docs.github.com/[email protected]/rest/reference/oauth-authorizations) will be removed on November, 13, 2020. For more information, including scheduled brownouts, see the [blog post](https://developer.github.com/changes/2020-02-14-deprecating-oauth-auth-endpoint/).
/authorizations/clients/{client_id}- Source
github-v3-rest.json- Revision
f5f067c1e6f6- Active snapshot
85e53e3d0d65
Request
Path Parameters
- client_id stringrequired
The client ID of your GitHub app.
Body Params
requiredThe OAuth app client secret for which to create the token.
A unique string to distinguish an authorization from others created for the same client ID and user.
A note to remind you what the OAuth token is for.
Example: Update all gems
A URL to remind you what app the OAuth token is for.
A list of scopes that this authorization is in.
[
"public_repo",
"user"
]Responses
if returning an existing token
Headers
Example: https://api.github.com/authorizations/1
app objectrequired
installation Scoped Installation objectoptionalnullable
account Simple User objectrequiredSimple User
Simple User
Example: https://github.com/images/error/octocat_happy.gif
Example: https://api.github.com/users/octocat/events{/privacy}
Example: https://api.github.com/users/octocat/followers
Example: https://api.github.com/users/octocat/following{/other_user}
Example: https://api.github.com/users/octocat/gists{/gist_id}
Example: 41d064eb2195891e12d0413f63227ea7
Example: https://github.com/octocat
Example: 1
Example: octocat
Example: MDQ6VXNlcjE=
Example: https://api.github.com/users/octocat/orgs
Example: https://api.github.com/users/octocat/received_events
Example: https://api.github.com/users/octocat/repos
Example: "2020-07-09T00:17:55Z"
Example: https://api.github.com/users/octocat/starred{/owner}{/repo}
Example: https://api.github.com/users/octocat/subscriptions
Example: User
Example: https://api.github.com/users/octocat
Example: true
permissions App Permissions objectrequiredThe permissions granted to the user-to-server access token.
Example:{
"contents": "read",
"deployments": "write",
"issues": "read",
"single_file": "read"
}
The permissions granted to the user-to-server access token.
{
"contents": "read",
"deployments": "write",
"issues": "read",
"single_file": "read"
}The level of permission to grant the access token for GitHub Actions workflows, workflow runs, and artifacts. Can be one of: `read` or `write`.
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`.
The level of permission to grant the access token for checks on code. Can be one of: `read` or `write`.
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`.
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`.
The level of permission to grant the access token for deployments and deployment statuses. Can be one of: `read` or `write`.
The level of permission to grant the access token for managing repository environments. Can be one of: `read` or `write`.
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`.
The level of permission to grant the access token for organization teams and members. Can be one of: `read` or `write`.
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`.
The level of permission to grant the access token to manage access to an organization. Can be one of: `read` or `write`.
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`.
The level of permission to grant the access token for organization packages published to GitHub Packages. Can be one of: `read` or `write`.
The level of permission to grant the access token for viewing an organization's plan. Can be one of: `read`.
The level of permission to grant the access token to manage organization projects and projects beta (where available). Can be one of: `read`, `write`, or `admin`.
The level of permission to grant the access token to manage organization secrets. Can be one of: `read` or `write`.
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`.
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`.
The level of permission to grant the access token for packages published to GitHub Packages. Can be one of: `read` or `write`.
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`.
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`.
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`.
The level of permission to grant the access token to manage repository projects, columns, and cards. Can be one of: `read`, `write`, or `admin`.
The level of permission to grant the access token to view and manage secret scanning alerts. Can be one of: `read` or `write`.
The level of permission to grant the access token to manage repository secrets. Can be one of: `read` or `write`.
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`.
The level of permission to grant the access token to manage just a single file. Can be one of: `read` or `write`.
The level of permission to grant the access token for commit statuses. Can be one of: `read` or `write`.
The level of permission to grant the access token to manage team discussions and related comments. Can be one of: `read` or `write`.
The level of permission to grant the access token to manage Dependabot alerts. Can be one of: `read` or `write`.
The level of permission to grant the access token to update GitHub Actions workflow files. Can be one of: `write`.
Example: https://api.github.com/users/octocat/repos
Describe whether all repositories have been selected or there's a selection involved
Example: config.yaml
[
"config.yml",
".github/issue_TEMPLATE.md"
]A list of scopes that this authorization is in.
user Simple User objectoptionalnullable Simple User
Simple User
Example: https://github.com/images/error/octocat_happy.gif
Example: https://api.github.com/users/octocat/events{/privacy}
Example: https://api.github.com/users/octocat/followers
Example: https://api.github.com/users/octocat/following{/other_user}
Example: https://api.github.com/users/octocat/gists{/gist_id}
Example: 41d064eb2195891e12d0413f63227ea7
Example: https://github.com/octocat
Example: 1
Example: octocat
Example: MDQ6VXNlcjE=
Example: https://api.github.com/users/octocat/orgs
Example: https://api.github.com/users/octocat/received_events
Example: https://api.github.com/users/octocat/repos
Example: "2020-07-09T00:17:55Z"
Example: https://api.github.com/users/octocat/starred{/owner}{/repo}
Example: https://api.github.com/users/octocat/subscriptions
Example: User
Example: https://api.github.com/users/octocat
**Deprecation Notice:** GitHub will discontinue the [OAuth Authorizations API](https://docs.github.com/[email protected]/rest/reference/oauth-authorizations), which is used by integrations to create personal access tokens and OAuth tokens, and you must now create these tokens using our [web application flow](https://docs.github.com/[email protected]/apps/building-oauth-apps/authorizing-oauth-apps/#web-application-flow). The [OAuth Authorizations API](https://docs.github.com/[email protected]/rest/reference/oauth-authorizations) will be removed on November, 13, 2020. For more information, including scheduled brownouts, see the [blog post](https://developer.github.com/changes/2020-02-14-deprecating-oauth-auth-endpoint/).
Headers
Example: https://api.github.com/authorizations/1
app objectrequired
installation Scoped Installation objectoptionalnullable
account Simple User objectrequiredSimple User
Simple User
Example: https://github.com/images/error/octocat_happy.gif
Example: https://api.github.com/users/octocat/events{/privacy}
Example: https://api.github.com/users/octocat/followers
Example: https://api.github.com/users/octocat/following{/other_user}
Example: https://api.github.com/users/octocat/gists{/gist_id}
Example: 41d064eb2195891e12d0413f63227ea7
Example: https://github.com/octocat
Example: 1
Example: octocat
Example: MDQ6VXNlcjE=
Example: https://api.github.com/users/octocat/orgs
Example: https://api.github.com/users/octocat/received_events
Example: https://api.github.com/users/octocat/repos
Example: "2020-07-09T00:17:55Z"
Example: https://api.github.com/users/octocat/starred{/owner}{/repo}
Example: https://api.github.com/users/octocat/subscriptions
Example: User
Example: https://api.github.com/users/octocat
Example: true
permissions App Permissions objectrequiredThe permissions granted to the user-to-server access token.
Example:{
"contents": "read",
"deployments": "write",
"issues": "read",
"single_file": "read"
}
The permissions granted to the user-to-server access token.
{
"contents": "read",
"deployments": "write",
"issues": "read",
"single_file": "read"
}The level of permission to grant the access token for GitHub Actions workflows, workflow runs, and artifacts. Can be one of: `read` or `write`.
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`.
The level of permission to grant the access token for checks on code. Can be one of: `read` or `write`.
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`.
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`.
The level of permission to grant the access token for deployments and deployment statuses. Can be one of: `read` or `write`.
The level of permission to grant the access token for managing repository environments. Can be one of: `read` or `write`.
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`.
The level of permission to grant the access token for organization teams and members. Can be one of: `read` or `write`.
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`.
The level of permission to grant the access token to manage access to an organization. Can be one of: `read` or `write`.
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`.
The level of permission to grant the access token for organization packages published to GitHub Packages. Can be one of: `read` or `write`.
The level of permission to grant the access token for viewing an organization's plan. Can be one of: `read`.
The level of permission to grant the access token to manage organization projects and projects beta (where available). Can be one of: `read`, `write`, or `admin`.
The level of permission to grant the access token to manage organization secrets. Can be one of: `read` or `write`.
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`.
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`.
The level of permission to grant the access token for packages published to GitHub Packages. Can be one of: `read` or `write`.
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`.
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`.
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`.
The level of permission to grant the access token to manage repository projects, columns, and cards. Can be one of: `read`, `write`, or `admin`.
The level of permission to grant the access token to view and manage secret scanning alerts. Can be one of: `read` or `write`.
The level of permission to grant the access token to manage repository secrets. Can be one of: `read` or `write`.
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`.
The level of permission to grant the access token to manage just a single file. Can be one of: `read` or `write`.
The level of permission to grant the access token for commit statuses. Can be one of: `read` or `write`.
The level of permission to grant the access token to manage team discussions and related comments. Can be one of: `read` or `write`.
The level of permission to grant the access token to manage Dependabot alerts. Can be one of: `read` or `write`.
The level of permission to grant the access token to update GitHub Actions workflow files. Can be one of: `write`.
Example: https://api.github.com/users/octocat/repos
Describe whether all repositories have been selected or there's a selection involved
Example: config.yaml
[
"config.yml",
".github/issue_TEMPLATE.md"
]A list of scopes that this authorization is in.
user Simple User objectoptionalnullable Simple User
Simple User
Example: https://github.com/images/error/octocat_happy.gif
Example: https://api.github.com/users/octocat/events{/privacy}
Example: https://api.github.com/users/octocat/followers
Example: https://api.github.com/users/octocat/following{/other_user}
Example: https://api.github.com/users/octocat/gists{/gist_id}
Example: 41d064eb2195891e12d0413f63227ea7
Example: https://github.com/octocat
Example: 1
Example: octocat
Example: MDQ6VXNlcjE=
Example: https://api.github.com/users/octocat/orgs
Example: https://api.github.com/users/octocat/received_events
Example: https://api.github.com/users/octocat/repos
Example: "2020-07-09T00:17:55Z"
Example: https://api.github.com/users/octocat/starred{/owner}{/repo}
Example: https://api.github.com/users/octocat/subscriptions
Example: User
Example: https://api.github.com/users/octocat
Not modified
Requires authentication
Forbidden
Validation failed