-
Couldn't load subscription status.
- Fork 7.3k
Clarify pre-existing token env var error during login #2658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify pre-existing token env var error during login #2658
Conversation
|
I would add quotes around the variable, aside of that I approve this pr |
|
An of course, thanks a ton @drewrisinger 🥇 |
Occurs when a pre-existing GITHUB_TOKEN or github enterprise token exists in the environment variables while running ``gh auth login``.
|
@drewrisinger it seems that I don't have permissions to approve your PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, our team is not around much until the 2nd week of January. 🙇
| if hostname != "" && key == "oauth_token" { | ||
| if token, env := AuthTokenFromEnv(hostname); token != "" { | ||
| return fmt.Errorf("read-only token in %s cannot be modified", env) | ||
| return fmt.Errorf("The '%s' environment variable is not empty, please clear it to save authentication data", env) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an improvement, but I'm not 100% sure either about this new error message. It makes it sound like setting GITHUB_TOKEN or GH_TOKEN in your environment is something wrong that you should clear to proceed.
Since setting environment variables is a perfectly valid way to authenticate, maybe the error message shouldn't instruct users to clear the environment variable, but should instruct them to change the token that's saved in the variable if they need to re-authenticate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options:
This command is not compatible with pre-existing environment variable '%s'. You will need to confirm & update the variable yourself as needed.Pre-existing login token '%s' recognized. If you want this application to manage your login, clear the environment variable.Pre-existing login token '%s' recognized. Re-authentication will require changing the environment variable manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the suggestions. Upon further deliberation, I decided that the config package isn't the right place to print an error message about environment variables being read-only. Instead, that responsibility should fall on auth commands themselves. I've opened an alternate PR here #2813
Summary
Clarifies the error and steps to remedy it when the GITHUB_TOKEN (or enterprise token) environment variable is set before
gh auth login.closes #2304
Details
Based on suggested text by @georgettica in #2304