Skip to content

Instantly share code, notes, and snippets.

@gary
Last active August 29, 2015 13:55
Show Gist options
  • Save gary/8720313 to your computer and use it in GitHub Desktop.
Save gary/8720313 to your computer and use it in GitHub Desktop.
Login to the GitHub API with 2fa and netrc
machine api.github.com
login # your GitHub username
password # your GitHub password
c = Octokit::Client.new netrc: true
t = c.create_authorization(scopes: ['user'], headers: { 'X-GitHub-OTP' => 'XXXXXX' }) # with your 2 factor code
c = Octokit::Client.new access_token: t.token
c.user # => should be you
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment