Skip to content

gh auth status should have a JSON output option #8637

@evilhamsterman

Description

@evilhamsterman

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"
        ]
    }
}

Metadata

Metadata

Assignees

Labels

enhancementa request to improve CLIgh-authrelating to the gh auth commandhelp wantedContributions welcome

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions