github-release-notes
github-release-notes copied to clipboard
Create token creation command
How to generate a token
URL: https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization
When making a request to that endpoint, if you don't specify a client_id and client_secret in the request, a personal access token will be created.
Here's an example curl -v request:
curl -v -u ":username" https://api.github.com/authorizations -X POST \
-d '{"scopes":["user"], "note":"token with user scope"}'
If you have two-factor authentication enabled and make the above request, the GitHub API will respond with the following message:
{
"message": "Must specify two-factor authentication OTP code.",
"documentation_url": "https://developer.github.com/v3/auth#working-with-two-factor-authentication"
}
At this point, you will need to send your authentication code (i.e., the one-time password) in the X-GitHub-OTP header like this:
curl -v -u ":username" https://api.github.com/authorizations -X POST \
-d '{"scopes":["user"], "note":"token with user scope"}' \
-H "X-GitHub-OTP: one_time_password" \