Skip to content

Add a command to expose the auth token directly #6277

Closed

Description

@anglinb

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.

Activity

  1. eriweb commented on Sep 20, 2022

    @eriweb

    Can't you use gh auth status -t to display the current token?

  2. anglinb commented on Sep 20, 2022

    @anglinb
    Author

    @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.

  3. samcoe commented on Sep 21, 2022

    @samcoe
    Contributor

    @anglinb You can use gh config get oauth_token -h github.com to retrieve the auth token without any other output text.

  4. vilmibm commented on Sep 21, 2022

    @vilmibm
    Contributor

    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.

  5. added and removed on Sep 21, 2022
  6. anglinb commented on Sep 21, 2022

    @anglinb
    Author

    Ah cool @samcoe proposed a solution that works but gh auth token is definitely cleaner, would love to see it! Thanks @vilmibm 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIhelp wantedContributions welcome

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions