ghi icon indicating copy to clipboard operation
ghi copied to clipboard

Auth token not working

Open templeman opened this issue 7 years ago • 8 comments

I know there are already a lot of other issues related to authentication, but I've been through all of them and none of the solutions have worked for me.

After using ghi successfully for some time, I recently tried ghi list and got

Authorization required.

Not authorized for this action with your token. To regenerate a new token:

Please run 'ghi config --auth <username>'

After looking through some of the issues on the repo I

  • Deleted all ghi tokens at https://github.com/settings/tokens
  • Searched in my keychain for "ghi". There was one entry. I deleted it, along with all other "github.com" entries.
  • Cleared the ghi entry in ~/.gitconfig
  • Re-ran ghi config --auth templeman

Doing all this gave me the thumbs-up from ghi: ✔︎ Token saved to keychain. However, when I try to use the ghi command I just get the same "Authorization required" message as before. I've rinsed and repeated several times with the same result.

I don't use SourceTree but I also tried the steps suggested here with the same result.

Finally, I tried the method described in #312 of manually generating a token on GitHub and running git config --global ghi.token <my generated token>, yet I still get the original "Authorization required" response.

It looks like the token is getting set properly, but for some reason is failing authentication. I did set up a GPG key for my GitHub account and I wonder if that could be interfering with ghi somehow?

templeman avatar Apr 04 '17 16:04 templeman

I'm having the same issue with ghi installed from homebrew.

adamyonk avatar May 26 '17 21:05 adamyonk

Gah… I had a GHI_TOKEN set in my env and it seems like that was overriding the config ghi.token setting. @templeman try checking for that.

adamyonk avatar May 26 '17 21:05 adamyonk

@adamyonk I double-checked across several repos and there is no overriding GHI_TOKEN setting for me. The 'Authorization required' message persists regardless of repo. I still suspect my GPG key but only because I can't think of any other possible conflict at this point.

templeman avatar Jun 15 '17 17:06 templeman

Here the same. Anything that i have tried wont help. Public repos works, but private i got an Auth Error. But i didn't found a key from GHI in my keychain.

gisu avatar Aug 07 '17 13:08 gisu

Had the same thing, #312 got me on the right track.

Generate a public access token with repo permissions in github manually (let's say the token is abcdefgxyz).

git config github.host github.mycompany.com
git config ghi.token abcdefxyz

ionsquare avatar Jun 27 '18 17:06 ionsquare

I have the same issue after installing with gem.

@ionsquare what is the github.host key for? Did it fix anything?

philipjhj avatar Oct 22 '18 10:10 philipjhj

@philipjhj yes I was able to fix my issue by using those options.

The github.host is used if you want to connect to an enterprise github that your employer might run on their own server. For example, if your github url is https://github.somecompany.org, you would run the command, git config github.host github.somecompany.org

To manually generate a token, click your profile icon in the top right then select Settings -> Developer Settings -> Personal access tokens -> Generate new token.

Then copy that token and run the command to set the token. For example, if your generated token was abcdefxyz, you would run this: git config ghi.token abcdefxyz.

The git config commands operate on the repo that you are currently working in, so you need to be in a cloned repo for it to work. There's always the --global option if you don't want to set it for each repo separately.

ionsquare avatar Oct 22 '18 15:10 ionsquare

@ionsquare Thanks for your detailed answer. However, I suspect that my issues are related to the issues on the server side of GitHub today. I will wait it out and test again.

Update: My issue seemed to have been solved after the system restore of github that happened today.

philipjhj avatar Oct 22 '18 16:10 philipjhj