Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@drewrisinger
Copy link

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

@georgettica
Copy link

I would add quotes around the variable, aside of that I approve this pr

@georgettica
Copy link

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``.
@georgettica
Copy link

@drewrisinger it seems that I don't have permissions to approve your PR
Ask around from maintainers :/

@drewrisinger
Copy link
Author

I understand it's the holidays, so no rush. CC'ing (hopefully, assuming) maintainers from the original thread @vilmibm @mislav

Copy link
Contributor

@mislav mislav left a 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)
Copy link
Contributor

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Options:

  1. This command is not compatible with pre-existing environment variable '%s'. You will need to confirm & update the variable yourself as needed.
  2. Pre-existing login token '%s' recognized. If you want this application to manage your login, clear the environment variable.
  3. Pre-existing login token '%s' recognized. Re-authentication will require changing the environment variable manually.

Copy link
Contributor

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

@drewrisinger drewrisinger deleted the dr-pr-issue-2304-ghtoken-message branch January 22, 2021 13:44
@drewrisinger drewrisinger restored the dr-pr-issue-2304-ghtoken-message branch January 22, 2021 13:44
@drewrisinger drewrisinger deleted the dr-pr-issue-2304-ghtoken-message branch January 22, 2021 13:44
@drewrisinger drewrisinger restored the dr-pr-issue-2304-ghtoken-message branch January 22, 2021 13:44
@drewrisinger drewrisinger deleted the dr-pr-issue-2304-ghtoken-message branch January 22, 2021 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

when GITHUB_TOKEN is set, print better messaging during gh auth login

3 participants