ColemanGariety / galileo

Search GitHub from your shell.
http://gariety.xxx/galileo
MIT License
160 stars 11 forks source link

Does not work with GitHub users who have enabled 2FA #2

Open ColemanGariety opened 10 years ago

cp commented 10 years ago

TFA?

ColemanGariety commented 10 years ago

@ColbyAley Two-factor authentication.

cp commented 10 years ago

Ah. 2FA. Check out how Hub does it. I generated a single use password and stuck it in my Netrc and it works perfectly.

morganestes commented 10 years ago

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 commented 10 years ago

https://github.com/octokit/octokit.rb#two-factor-authentication

ColemanGariety commented 10 years ago

@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
jasonyost commented 10 years ago

@morganestes commented on Jan 28 - This worked perfectly for me.

ColemanGariety commented 10 years ago

Thanks, @morganestes!