Open ColemanGariety opened 10 years ago
@ColbyAley Two-factor authentication.
Ah. 2FA. Check out how Hub does it. I generated a single use password and stuck it in my Netrc and it works perfectly.
Got it to work by generating a token in my account (https://github.com/settings/applications) for galileo, then adding this line to my ~/.netrc
file:
machine api.github.com login <my username> password <generated token>
Restart your terminal shell (or open a new one) and galileo should pick up your settings.
@evantravers @ColbyAley played around with this for ~45 minutes and can't get it working. I make the request, it throws 401, but my phone never receives a text with a new 2FA. I figured the old one hasn't expired, but if I pass that one it throws Must specify two-factor authentication OTP code.
Here's what I wrote up:
client = Octokit::Client.new netrc: true, auto_paginate: true
user = begin
client.user # attempt login without OTP
rescue Octokit::OneTimePasswordRequired
otp = [(print 'OTP: '), STDIN.noecho(&:gets).rstrip][1] # get the OTP via gets
client.create_authorization scopes: ['user'], headers: { 'X-GitHub-OTP' => otp } # get an OAuth2 token for re-use
end
@morganestes commented on Jan 28 - This worked perfectly for me.
Thanks, @morganestes!
TFA?