Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ColemanGariety opened this issue Jan 15, 2014 · 8 comments
Open

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

ColemanGariety opened this issue Jan 15, 2014 · 8 comments
Assignees

Comments

@ColemanGariety
Copy link
Owner

No description provided.

@cp
Copy link

cp commented Jan 15, 2014

TFA?

@ColemanGariety
Copy link
Owner Author

@ColbyAley Two-factor authentication.

@cp
Copy link

cp commented Jan 15, 2014

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
Copy link

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
Copy link

@ghost ghost assigned ColemanGariety Jan 31, 2014
@ColemanGariety
Copy link
Owner Author

@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
Copy link

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

@ColemanGariety
Copy link
Owner Author

Thanks, @morganestes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants