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
{{ message }}
Repository navigation
Add a command to expose the auth token directly #6277
Describe the feature or problem you’d like to solve
There are many instance when I quickly get a token (Ex: Authenticating with package registries, quickly cloning something on a remote machine, etc). The cli is the perfect place to allow developers to mint variable length tokens.
Right now, I open vim and copy the token from hosts.yml when I need it.
Proposed solution
gh auth token which returns the current token
Additionally, the command could take parameters like --repo, --expiration or --scopes to allow the token to be quickly scoped down to only required permissions.
Additional context
Add any other context like screenshots or mockups are helpful, if applicable.
@terbolous you can but then I have to parse the output manually if I want to pipe that anywhere, which I could do but would be annoying and prone to breaking if the output text ever changes.
We're ok with adding gh auth token but for now it would just be for printing tokens. It should only take one flag, --hostname, which defaults to the default host for gh.
Activity
eriweb commentedon Sep 20, 2022
Can't you use
gh auth status -tto display the current token?anglinb commentedon Sep 20, 2022
@terbolous you can but then I have to parse the output manually if I want to pipe that anywhere, which I could do but would be annoying and prone to breaking if the output text ever changes.
samcoe commentedon Sep 21, 2022
@anglinb You can use
gh config get oauth_token -h github.comto retrieve the auth token without any other output text.vilmibm commentedon Sep 21, 2022
We're ok with adding
gh auth tokenbut for now it would just be for printing tokens. It should only take one flag,--hostname, which defaults to the default host forgh.anglinb commentedon Sep 21, 2022
Ah cool @samcoe proposed a solution that works but
gh auth tokenis definitely cleaner, would love to see it! Thanks @vilmibm 🙇