-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Describe the feature or problem you’d like to solve
There isn't a good way to easily integrate tools with the gh command to use the token. For example to create a Docker credential helper like in #5150 because the current output of gh auth status is formatted for human viewing and isn't guaranteed to remain stable.
Proposed solution
The command gh auth status should have an optional JSON output option to allow for integration with other tools that might need to use a Github token.
You can get just the token with gh auth token but it could be helpful to have other information such as the username, and the scopes. That way if necessary a command could run a gh auth refresh --scopes <scope> if the appropriate scope is not available. So for example a Docker credential helper as mentioned above could check if the token has the "read:packages" or even "write:packages" scope if necessary to push.
Additional context
An example output could be something like
{
"github.com": {
"active": true,
"token": "gho_*******",
"scopes": [
"gist",
"repo",
"write:packages"
]
}
}