You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bugSomething isn't workingdiscussFeature changes that require discussion primarily among the GitHub CLI teamgh-authrelating to the gh auth commandmore-info-neededMore info needed from user/contributorneeds-triageneeds to be reviewed
If it's happening when you're opening a new terminal, and you're having to set GITHUB_TOKEN= to clear it out, you probably have something in your shell startup scripts that is setting GITHUB_TOKEN.
That said, I wouldn't expect you need to auth login each time after clearing the environment variable. Can you provide the output of gh auth status before steps 1, 2, and 3. Thanks.
Also, where is this terminal? Is it inside an editor? What do you mean when you say "It happens after opening another project". What does opening mean in this context?
@williammartin Right, so I use VSCode and just recently cursor.sh (VSCode fork project) and when I say opening another project I mean switching opening a new workspace / project folder. That parts not consistent though. The consistent part is that it happens often haha.
Yep, just happened again on not a new project... I did this literally yesterday:
gh auth status
X Failed to log in to github.com using token (GITHUB_TOKEN)
- Active account: true
- The token in GITHUB_TOKEN is invalid.
✓ Logged in to github.com account ZackPlauche (keyring)
- Active account: false
- Git operations protocol: https
- Token: gho_************************************
- Token scopes: 'gist', 'read:org', 'repo', 'workflow'
It says "logged in to github.com account" with a checkmark but if I run something as simple as gh browse it throws the same auth error :/
gh browse
unable to determine base repository: HTTP 401: Bad credentials (https://api.github.com/graphql)
Try authenticating with: gh auth login
I just opened the project again today and logged in.
Just deleted the current token and logged in again and it said this:
gh auth login
? Where do you use GitHub? GitHub.com
? What is your preferred protocol for Git operations on this host? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser
! First copy your one-time code: ****-****
Press Enter to open https://github.com/login/device in your browser...
✓ Authentication complete.
- gh config set -h github.com git_protocol https
✓ Configured git protocol
✓ Logged in as ZackPlauche
! You were already logged in to this account
The line You were already logged in to this account is confusing.
Also just ran gh auth status again and it's not even showing the token...
gh auth status
github.com
✓ Logged in to github.com account ZackPlauche (keyring)
- Active account: true
- Git operations protocol: https
- Token: gho_************************************
- Token scopes: 'gist', 'read:org', 'repo', 'workflow'
Update, after my last comment, I just closed and opened the editor again and it's showing the invalid GITHUB_TOKEN message again after running gh auth status. But still says logged in 🤷♂️
gh auth status
github.com
X Failed to log in to github.com using token (GITHUB_TOKEN)
- Active account: true
- The token in GITHUB_TOKEN is invalid.
✓ Logged in to github.com account ZackPlauche (keyring)
- Active account: false
- Git operations protocol: https
- Token: gho_************************************
- Token scopes: 'gist', 'read:org', 'repo', 'workflow'
Right so when GITHUB_TOKEN is set, gh will always use that to authenticate with github.com. When you open a new project in VSCode, it's going to open new terminal, just like you doing it manually. So something is setting the GITHUB_TOKEN environment variable and it's not setting the value to an actually valid token.
After you unset GITHUB_TOKEN you shouldn't need to auth login again, it'll just start using the other token listed in gh auth status here:
✓ Logged in to github.com account ZackPlauche (keyring)
- Active account: false
- Git operations protocol: https
- Token: gho_************************************
- Token scopes: 'gist', 'read:org', 'repo', 'workflow'
I think something that would make this clearer is if we updated this to say something like:
✓ Logged in to github.com account ZackPlauche (keyring)
- Superseded by GITHUB_TOKEN environment variable
- Active account: false
- Git operations protocol: https
- Token: gho_************************************
- Token scopes: 'gist', 'read:org', 'repo', 'workflow'
I suggest that you grep your shell startup files for GITHUB_TOKEN.
Right so when GITHUB_TOKEN is set, gh will always use that to authenticate with github.com. When you open a new project in VSCode, it's going to open new terminal, just like you doing it manually. So something is setting the GITHUB_TOKEN environment variable and it's not setting the value to an actually valid token.
After you unset GITHUB_TOKEN you shouldn't need to auth login again, it'll just start using the other token listed in gh auth status here:
✓ Logged in to github.com account ZackPlauche (keyring)
- Active account: false
- Git operations protocol: https
- Token: gho_************************************
- Token scopes: 'gist', 'read:org', 'repo', 'workflow'
I think something that would make this clearer is if we updated this to say something like:
✓ Logged in to github.com account ZackPlauche (keyring)
- Superseded by GITHUB_TOKEN environment variable
- Active account: false
- Git operations protocol: https
- Token: gho_************************************
- Token scopes: 'gist', 'read:org', 'repo', 'workflow'
I suggest that you grep your shell startup files for GITHUB_TOKEN.
Yeah so unsetting the github token worked. I'm not quite sure how to grep for what's setting it but unsetting is good enough for now lol.
Yeah so unsetting the github token worked. I'm not quite sure how to grep for what's setting it but unsetting is good enough for now lol.
Maybe something like grep -d skip "GITHUB_TOKEN" ~/*.
So I just did Win and searched for environment variables and deleted it there and now it seems to have worked. Not sure how it got there in the first place but looks like it's fixed 🙂.
bugSomething isn't workingdiscussFeature changes that require discussion primarily among the GitHub CLI teamgh-authrelating to the gh auth commandmore-info-neededMore info needed from user/contributorneeds-triageneeds to be reviewed
Activity
williammartin commentedon Dec 7, 2024
If it's happening when you're opening a new terminal, and you're having to
set GITHUB_TOKEN=to clear it out, you probably have something in your shell startup scripts that is settingGITHUB_TOKEN.That said, I wouldn't expect you need to
auth logineach time after clearing the environment variable. Can you provide the output ofgh auth statusbefore steps 1, 2, and 3. Thanks.Also, where is this terminal? Is it inside an editor? What do you mean when you say "It happens after opening another project". What does opening mean in this context?
ZackPlauche commentedon Dec 7, 2024
@williammartin Right, so I use VSCode and just recently cursor.sh (VSCode fork project) and when I say opening another project I mean switching opening a new workspace / project folder. That parts not consistent though. The consistent part is that it happens often haha.
Yep, just happened again on not a new project... I did this literally yesterday:
It says "logged in to github.com account" with a checkmark but if I run something as simple as
gh browseit throws the same auth error :/I just opened the project again today and logged in.
Just deleted the current token and logged in again and it said this:
The line
You were already logged in to this accountis confusing.Also just ran
gh auth statusagain and it's not even showing the token...ZackPlauche commentedon Dec 7, 2024
Update, after my last comment, I just closed and opened the editor again and it's showing the invalid GITHUB_TOKEN message again after running
gh auth status. But still says logged in 🤷♂️williammartin commentedon Dec 7, 2024
Right so when
GITHUB_TOKENis set,ghwill always use that to authenticate with github.com. When you open a new project in VSCode, it's going to open new terminal, just like you doing it manually. So something is setting theGITHUB_TOKENenvironment variable and it's not setting the value to an actually valid token.After you
unset GITHUB_TOKENyou shouldn't need toauth loginagain, it'll just start using the other token listed ingh auth statushere:I think something that would make this clearer is if we updated this to say something like:
I suggest that you grep your shell startup files for
GITHUB_TOKEN.williammartin commentedon Dec 7, 2024
I also think that we could update this message:
So that if the invalid token is coming from
GITHUB_TOKENenv var that we don't recommend trying to log in but to fix the value of your token.ZackPlauche commentedon Dec 11, 2024
Yeah so unsetting the github token worked. I'm not quite sure how to grep for what's setting it but unsetting is good enough for now lol.
williammartin commentedon Dec 11, 2024
Maybe something like
grep -d skip "GITHUB_TOKEN" ~/*.ZackPlauche commentedon Dec 11, 2024
So I just did Win and searched for environment variables and deleted it there and now it seems to have worked. Not sure how it got there in the first place but looks like it's fixed 🙂.
williammartin commentedon Dec 12, 2024
Great, thanks for letting us know.