maboloshi
2/18/2019 - 1:31 AM

[为github创建私人访问令牌] #github

[为github创建私人访问令牌] #github

Generating Access Token

As of 2013-05-16, you can generate API Access Tokens via the Web UI or via the GitHub API. All other authorization methods is deprecated.

Web

  • Account Settings -> Personal access tokens
  • "Generate new token" under "Personal access tokens"
  • For "Token description" you should give it a meaningful name, Example: sublime gist
  • Under "Select scopes" you can just select gist

Paste the token in the settings section under the token option.

API

Here's a command you can run from your terminal to generate a token via curl:

curl -i -u USERNAME https://api.github.com/authorizations --data '{"scopes":["gist"],"note":"SublimeText 2/3 Gist plugin"}'

Where USERNAME is your Github username. Save the token generated and paste it in the settings section under the token option.

If OTP is enabled on your account, this will return 401 error code, use:

curl -i -u USERNAME -H "X-GitHub-OTP: OTPCODE" https://api.github.com/authorizations --data '{"scopes":["gist"],"note":"SublimeText 2/3 Gist plugin"}'

Where OTPCODE is the code your authenticator app shows you.

摘取至: https://github.com/condemil/Gist/blob/master/README.md