Basic Authentication

The API supports Basic Authentication as defined in RFC2617 with a few slight differences. The main difference is that the RFC requires unauthenticated requests to be answered with 401 Unauthorized responses. In many places, this would disclose the existence of user data. Instead, the GitHub Enterprise API responds with 404 Not Found. This may cause problems for HTTP libraries that assume a 401 Unauthorized response. The solution is to manually craft the Authorization header.

Via OAuth and personal access tokens

We recommend you use OAuth tokens to authenticate to the GitHub API. OAuth tokens include personal access tokens and enable the user to revoke access at any time.

curl -u username:token http(s)://[hostname]/api/v3/user

This approach is useful if your tools only support Basic Authentication but you want to take advantage of OAuth access token security features.

Via username and password

Deprecation Notice: GitHub will discontinue password authentication to the API. You must now authenticate to the GitHub API with an API token, such as an OAuth access token, GitHub App installation access token, or personal access token, depending on what you need to do with the token. For more information, see the blog post.

To use Basic Authentication with the GitHub Enterprise API, simply send the username and password associated with the account.

For example, if you're accessing the API via cURL, the following command would authenticate you if you replace <username> with your GitHub Enterprise username. (cURL will prompt you to enter the password.)

curl -u username http(s)://[hostname]/api/v3/user

If you have two-factor authentication enabled, make sure you understand how to work with two-factor authentication.