magit/ghub

Prompted for 2FA code, yet get error "Must specify two-factor authentication OTP code"

Closed this issue ยท 10 comments

Thank you for your great work on the Magit ecosystem.

I am trying to get up and running with opening pull requests from within Spacemacs. My auth-sources is set to ("~/.authinfo.gpg" "~/.authinfo" "~/.netrc"). Having entered my username, my GitHub password, and then the 2FA code---which I was not only prompted for, but received---I get the following error, and am unable to complete:

ghub--confirm-create-token: HTTP Error: 401, "Unauthorized", "/authorizations", ((message . "Must specify two-factor authentication OTP code.") (documentation_url . "https://developer.github.com/v3/auth#working-with-two-factor-authentication")) [2 times]

I tried this twice (thus with two separate 2FA codes) to make sure I did not enter the 2FA code incorrectly.

Let me know what else I can do to debug this issue or whatever other information I can provide.

I can reproduce the issue but it will likely be weeks until I can investigate this. So you should probably create the token manually, as documented in the manual.

@tarsius Thank you for your response. I will give the manual approach a shot.

@tarsius I did not have GPG set up either. I got that set up and used that to put an encrypted key in ~/.authinfo.gpg. It worked! And, I am absolutely blown away. I was looking for something simple and basic, but now I can actual browse PRs complete with discussion and emojis and everything mind blown. I did have to authorize an SSO organization myself, too; I don't know if the code would have done that for me (if the above had worked). Anyway, thanks again. I'll leave the issue open sine you said you can reproduce, but for my purposes, I am in the clear at this point.

I also am experiencing this error setting up forge. Manually adding in '~/.authinfo' doesn't seem to fix it for me. From some debugging it looks like it's being picked up though.

auth-source-search: found 3 backends matching (:host "api.github.com" :user "dalton-verkada^forge" :max 1)
auth-source-search-backend: got 1 (max 1) in netrc:~/.authinfo matching (:host "api.github.com" :user "dalton-verkada^forge" :max 1)
auth-source-search: found 1 results (max 1) matching (:host "api.github.com" :user "dalton-verkada^forge" :max 1)

Hopefully this will help your investigation!

@Kazark Thanks ๐Ÿ˜

FWIW same problem here, but manual token creation worked.

Was able to resolve it by adding a token to the ~/.authinfo

machine api.github.com login <login>^<package> password <token>

where <package> in my case was forge.

manual link

I wouldn't say that you "resolved" it, more that you "worked around" it. I did the same. but it would be cool to have this working like before ๐Ÿ˜

Github will stop supporting password authentication as whole in a few months. Because of that I don't plan to fix two-factor authentication--it would buy as a few months at best. Instead I intend to remove the wizard completely. For more information see #113.

Instead I intend to remove the wizard completely.

Done.