gitgithubcommand-line-interface

Does 'gh auth login' create a GITHUB_TOKEN or GH_TOKEN?


GITHUB_TOKEN can be used in automated workflows, and I was wondering if running the cli command gh auth login and authenticating successfully create an access token of some kind that can be read from the file system somewhere, and used for things like Github API.


Solution

  • Yes, an access token is generated for use by the GitHub CLI app (gh) when you login: using the scopes that you granted at the time you approved it for your account.

    However, if you need tokens for your own uses then you should create one for each use case. Re-using tokens for other purposes is an anti-pattern:

    If the program or PAT is compromised, the damage will be limited by the permissions available to that PAT, and the PAT itself can easily be revoked to prevent further exploitation.