Skip to content

Support GH_TOKEN #1229

@zx8

Description

@zx8

#976 taught gh to respect the GITHUB_TOKEN environment variable. Unfortunately, I already use this environment variable for other tools, and as such it has the absolute minimum set of scopes attached to it for security purposes.

Now that gh has started use this environment variable, I'm getting the following error:

Warning: gh now requires the `read:org` OAuth scope.
Visit https://github.com/settings/tokens and edit your token to enable `read:org`
or generate a new token for the GITHUB_TOKEN environment variable
graphql error: 'Your token has not been granted the required scopes to execute this query. The 'name' field requires one of the following scopes: ['read:org', 'read:discussion'], but your token has only been granted the: ['repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.'

I don't want to grant this token additional scopes because it is not required for the other tools that use it.

Possible solutions:

  • Rename GITHUB_TOKEN to GITHUB_GH_TOKEN and avoid clashes altogether
  • Unset GITHUB_TOKEN to allow OAuth flow to take precedence (i.e. create a wrapper script which invokes GITHUB_TOKEN= command gh "$@")
  • Let the user specify which auth method should take precedence – in my case, I specifically do not want to use the GITHUB_TOKEN method

Thoughts?

Metadata

Metadata

Assignees

Labels

authrelated to tokens, authentication state, or oauthbugSomething isn't workingpriority-2Affects more than a few users but doesn't prevent core functions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions