magit / ghub

Client libraries for the APIs of various Git forges

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cannot obtain token while 2FA is enabled in Github

shackra opened this issue · comments

Hello!

trying to retrieve my Github token but after entering the password of my Github account the process fails, this is what I was able to gather from the backtrace:

Debugger entered--Lisp error: (error "Wrong authorization used for https://api.github.com/authorizations")
  signal(error ("Wrong authorization used for https://api.github.com/authorizations"))
  error("Wrong authorization used for %s" "https://api.github.com/authorizations")
  url-http-handle-authentication(nil)
  url-http-parse-headers()
  url-http-content-length-after-change-function(900 1061 161)
  url-http-wait-for-headers-change-function(1 1082 1081)
  url-http-generic-filter(#<process api.github.com> "HTTP/1.1 401 Unauthorized\15\nServer: GitHub.com\15\nDate: Mon, 27 Jan 2020 22:12:57 GMT\15\nContent-Type: application/json; charset=utf-8\15\nContent-Length: 160\15\nStatus: 401 Unauthorized\15\nX-GitHub-OTP: required; app\15\nX-GitHub-Media-Type: github.v3; format=json\15\nX-RateLimit-Limit: 60\15\nX-RateLimit-Remaining: 45\15\nX-RateLimit-Reset: 1580163381\15\nAccess-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type\15\nAccess-Control-Allow-Origin: *\15\nStrict-Transport-Security: max-age=31536000; includeSubdomains; preload\15\nX-Frame-Options: deny\15\nX-Content-Type-Options: nosniff\15\nX-XSS-Protection: 1; mode=block\15\nReferrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin\15\nContent-Security-Policy: default-src 'none'\15\nX-GitHub-Request-Id: 922C:4750:42A4:979E:5E2F6068\15\n\15\n{\"message\":\"Must specify two-factor authentication OTP code.\",\"documentation_url\":\"https://developer.github.com/v3/auth#working-with-two-factor-authentication\"}")
  accept-process-output(#<process api.github.com> 1)
  url-retrieve-synchronously(#s(url :type "https" :user nil :password nil :host "api.github.com" :portspec nil :filename "/authorizations" :target nil :attributes nil :fullness t :silent nil :use-cookies t :asynchronous nil) nil)
  ghub--retrieve("{\"scopes\":[\"repo\",\"user\",\"read:org\"],\"note\":\"Emacs..." #s(ghub--req :url #s(url :type "https" :user nil :password nil :host "api.github.com" :portspec nil :filename "/authorizations" :target nil :attributes nil :fullness t :silent nil :use-cookies t :asynchronous nil) :forge nil :silent nil :method "POST" :headers #f(compiled-function () #<bytecode 0xb275d7462302eff>) :handler ghub--handle-response :unpaginate nil :noerror nil :reader nil :callback nil :errorback nil :value nil :extra nil))
  ghub-request("POST" "/authorizations" ((scopes repo user read:org) (note . "Emacs package forge @ pequod")) :query nil :payload nil :headers nil :silent nil :unpaginate nil :noerror nil :reader nil :username "shackra" :auth basic :host "api.github.com" :callback nil :errorback nil :extra nil)
  ghub-post("/authorizations" ((scopes repo user read:org) (note . "Emacs package forge @ pequod")) :username "shackra" :auth basic :host "api.github.com")
  ghub-create-token("api.github.com" "shackra" forge (repo user read:org))
  ghub--confirm-create-token("api.github.com" "shackra" forge)
  ghub--token("api.github.com" "shackra" forge nil nil)
  ghub--auth("api.github.com" forge "shackra" nil)
  #f(compiled-function () #<bytecode -0x13dcb22f3f5dd10d>)()
  ghub--retrieve("{\"query\":\"query ($owner:String!, $name:String!) {\\n                 repository(owner:$owner, name:$name) { id }\\n               }\",\"variables\":{\"owner\":\"CompanyX-Group\",\"name\":\"ProjectX-UI\"}}" #s(ghub--req :url #s(url :type "https" :user nil :password nil :host "api.github.com" :portspec nil :filename "/graphql" :target nil :attributes nil :fullness t :silent nil :use-cookies t :asynchronous t) :forge nil :silent nil :method "POST" :headers #f(compiled-function () #<bytecode -0x13dcb22f3f5dd10d>) :handler ghub--handle-response :unpaginate nil :noerror nil :reader nil :callback nil :errorback nil :value nil :extra nil))
  ghub-request("POST" "/graphql" nil :payload "{\"query\":\"query ($owner:String!, $name:String!) {\\..." :silent nil :username nil :auth forge :host "api.github.com" :callback nil :errorback nil :extra nil :value nil)
  ghub-graphql("query ($owner:String!, $name:String!) {\n                 repository(owner:$owner, name:$name) { id }\n               }" ((owner . "CompanyX-Group") (name . "ProjectX-UI")) :username nil :auth forge :host "api.github.com")
  ghub--repository-id("CompanyX-Group" "ProjectX-UI" :username nil :auth forge :host "api.github.com")
  ghub-repository-id("CompanyX-Group" "ProjectX-UI" :host "api.github.com" :auth forge :forge github)

...

Yes, that doesn't appear to work anymore. It's a different error, but I think this is basically #104 anyway.