-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
auth status #1495
auth status #1495
Conversation
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.
This looks good so far! One tiny but important request: when authentication fails, would this command give you the instructions on how to fix the problem? That's what I imagined the whole point of the command to be.
For example (rough sketch):
# credentials from hosts.yml
$ gh auth status
github.com: authentication failed
The currently stored token has expired. To re-authenticate, run `gh auth login -h github.com`
# credentials from GITHUB_TOKEN
$ gh auth status
github.com: authentication failed
The token in your GITHUB_TOKEN environment variable is invalid. Generate a new token at
https://github.com/settings/tokens and give it "repo", "read:org", and "gist" scopes.
My experience with hub is that often people set GITHUB_TOKEN in their environment and forget about it until the token expires and suddenly none of the commands work anymore. They try to check their credentials in ~/.config/hub
and those might be fine, but only later they discover they had an environment variable too. So I'm thinking that our error messages should ideally be explicit about where the token came from in the first place.
Also, would the command list the preferred git clone protocol for each host, or is that planned as follow-up?
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.
@vilmibm and I worked through some design changes for the output, and came up with this!
discussion from sync: have status "print" tokens with *** and accept a flag to show the token. users may still want to view their tokens in order to authenticate in some other, headless environment. printing the token means they don't have to open the config file or depend on the |
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.
Just nits; but overall looks great 🏆
@ampinsk Updated the formatting! (...i ran auth refresh...) |
NB: I opened a new issue for the token printing behavior instead of tacking that into this already-reviewed PR: #1514 |
@vilmibm looks good!! one thing: those indentations look pretty big, I was thinking similar space to the indentation we have on
|
@ampinsk done |
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.
🎉 🎉
This PR adds
gh auth status
.Bad states:
Good state:
If
GITHUB_TOKEN
is specified in the environment, a single status check is done against it:bad:
good:
I added
--hostname
; if specified, just that host is checked (either against GITHUB_TOKEN or the token from the config).Part of #1413