github-release-notes icon indicating copy to clipboard operation
github-release-notes copied to clipboard

Create token creation command

Open alexcanessa opened this issue 8 years ago • 1 comments

Coming from #83

Create the $GREN_GITHUB_TOKEN using the API to generate a personal access token

alexcanessa avatar Dec 08 '17 11:12 alexcanessa

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" \

alexcanessa avatar Dec 08 '17 11:12 alexcanessa