github_cli icon indicating copy to clipboard operation
github_cli copied to clipboard

gcli authorize gives error after entering password

Open gijzelaerr opened this issue 6 years ago • 4 comments

$ gcli authorize
login: gijzelaerr
password:
Fatal error has occurred. You can only access your own tokens via Basic AuthenticationArgumentError: You can only access your own tokens via Basic Authentication
/usr/local/lib/ruby/gems/2.4.0/gems/github_api-0.17.0/lib/github_api/client/authorizations.rb:136:in `raise_authentication_error'
/usr/local/lib/ruby/gems/2.4.0/gems/github_api-0.17.0/lib/github_api/client/authorizations.rb:76:in `create'
/usr/local/lib/ruby/gems/2.4.0/gems/github_api-0.17.0/lib/github_api/api.rb:237:in `block in execute'
/usr/local/lib/ruby/gems/2.4.0/gems/github_api-0.17.0/lib/github_api/api.rb:224:in `run_callbacks'
/usr/local/lib/ruby/gems/2.4.0/gems/github_api-0.17.0/lib/github_api/api.rb:236:in `execute'
/usr/local/lib/ruby/gems/2.4.0/gems/github_api-0.17.0/lib/github_api/api.rb:196:in `block in method_added'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/apis/authorization.rb:22:in `block in create'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/api.rb:64:in `block in output'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/dsl.rb:19:in `on_error'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/api.rb:63:in `output'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/apis/authorization.rb:21:in `create'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/commands/authorizations.rb:54:in `create'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/vendor/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/vendor/thor/invocation.rb:120:in `invoke_command'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/vendor/thor.rb:363:in `dispatch'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/vendor/thor/invocation.rb:109:in `invoke'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/cli.rb:108:in `authorize'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/vendor/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/vendor/thor/invocation.rb:120:in `invoke_command'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/vendor/thor.rb:363:in `dispatch'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/vendor/thor/base.rb:438:in `start'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/bin/gcli:9:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/lib/github_cli/dsl.rb:19:in `on_error'
/usr/local/lib/ruby/gems/2.4.0/gems/github_cli-0.6.2/bin/gcli:9:in `<top (required)>'
/usr/local/bin/gcli:22:in `load'
/usr/local/bin/gcli:22:in `<main>'%                                                                                                                                                                                                           

gijzelaerr avatar Oct 05 '17 12:10 gijzelaerr

For what it's worth I'm seeing the same thing (ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin17].

wspr avatar Nov 19 '17 12:11 wspr

This gem hasn't been released since 2013. Many a thing has changed in the GitHub official api and I would be super impressed if this gem still worked. Equally, it is more prudent to use api through authorisation tokens rather than basic auth. I have intention to ressurect this gem but currently tty-* components take up majority of my open source time. Happy to review any PRs!

piotrmurach avatar Nov 19 '17 12:11 piotrmurach

Oh, I didn’t realise it was so historic — totally understandable then. Thanks for the quick reply. I really like the idea of the package, but no promise of getting around to a PR (same sort of situation).

wspr avatar Nov 19 '17 12:11 wspr

I can confirm the released version of the github_cli (version 0.6.2) has this issue. To reproduce:

$ gem install github_cli
$ gcli init -l
Writing new configuration file to /Users/danielkehoe/workspace/.githubrc
$ gcli authorize
login: DanielKehoe
password:
Fatal error has occurred. You can only access your own tokens via Basic AuthenticationArgumentError: You can only access your own tokens via Basic Authentication

Here's a workaround:

Go to https://github.com/settings/tokens and create a personal access token for github_cli with repo permissions. Copy the access token and paste into the file .githubrc, with username and password:

user.token: long_string
user.login: DanielKehoe
user.password: my_password

Then test, for example:

$ gcli content readme DanielKehoe github_api
Response Status: 200

So it's possible to use the released version 0.6.2 of github_cli.

I tried cloning from the repo and building and installing the 0.7.0 unreleased version of the gem but encountered "401 - Bad credentials" errors (I'll open a new issue for this).

DanielKehoe avatar May 23 '20 07:05 DanielKehoe