Skip to content

Instantly share code, notes, and snippets.

@lawrencejones
Created May 15, 2015 11:39
Show Gist options
  • Save lawrencejones/39e0a40f89751c7aaf46 to your computer and use it in GitHub Desktop.
Save lawrencejones/39e0a40f89751c7aaf46 to your computer and use it in GitHub Desktop.
Create a github auth token
gem 'octokit'
require 'octokit'
print "Login: "; login = gets.chomp
print "Password: "; password = `read -s password; echo $password`.chomp
print "\nTwo factor auth: "; two_factor = gets.chomp
gh = Octokit::Client.new(
login: login,
password: password
)
auth = gh.create_authorization(
scopes: [:repo, :notifications],
note: "Clippy dev",
headers: { "X-GitHub-OTP" => two_factor }
)
puts "Generated token: \"#{auth[:token]}\""
puts JSON.pretty_generate(auth.to_h)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment