GitHub shell plugin fails to authenticate with enterprise server

dvanoni
dvanoni
Community Member

I'm attempting to use the GitHub shell plugin with my company's self-hosted GitHub Enterprise Server (which uses a custom host name). When I run gh auth status, I receive the following error:

custom.host.name
  X custom.host.name: authentication failed
  - The custom.host.name token in oauth_token is no longer valid.
  - To re-authenticate, run: gh auth login -h custom.host.name
  - To forget about this host, run: gh auth logout -h custom.host.name

github.com
  X github.com: authentication failed
  - The github.com token in GITHUB_TOKEN is no longer valid.

(I've swapped out the actual host name with custom.host.name above.)

In my 1Password item, I've set both the token and host fields. My understanding based on reading the shell plugin docs is that these fields will be exposed as the GH_TOKEN and GH_HOST environment variables, respectively.

I have a hunch that the issue is that, for GitHub Enterprise, the GitHub CLI expects the token to be available in the GH_ENTERPRISE_TOKEN environment variable instead of GH_TOKEN. This is based on my reading of the output of gh help environment:

GH_TOKEN, GITHUB_TOKEN (in order of precedence): an authentication token for github.com
API requests. Setting this avoids being prompted to authenticate and takes precedence over
previously stored credentials.

GH_ENTERPRISE_TOKEN, GITHUB_ENTERPRISE_TOKEN (in order of precedence): an authentication
token for API requests to GitHub Enterprise. When setting this, also set GH_HOST.

GH_HOST: specify the GitHub hostname for commands that would otherwise assume the
"github.com" host when not in a context of an existing repository.

Does this seem like the source of the issue? If so, would it make sense to add support for an enterprise token field in the 1Password item that is exposed as GH_ENTERPRISE_TOKEN?

Thanks!


1Password Version: 8.9.11
Extension Version: CLI 2.12.0
OS Version: macOS 12.6.1
Browser:_ Not Provided
Referrer: forum-search:GitHub shell plugin fails to authenticate with

Comments

  • Hey @dvanoni, thank you for reaching out to us! As far as I can see, your hunch looks to be correct.

    I have opened an issue on the Shell Plugins public repository about this: https://github.com/1Password/shell-plugins/issues/137

    We think this would be an awesome addition to the GitHub plugin.

    Shell Plugins are open to contributions, so in case you or anyone else would be interested in carrying out these changes, don't hesitate to reach out to us here or on GitHub for any help or inquiries.

    Thank you for raising this!

    Best,
    Horia

This discussion has been closed.