Skip to content
This repository was archived by the owner on Oct 30, 2025. It is now read-only.
This repository was archived by the owner on Oct 30, 2025. It is now read-only.

[FEAT]: Allow personal access tokens to be used with gh-copilot #116

Open

Description

@andyfeller

Thanks for taking the time to fill out this out! 🙇
By submitting this issue, you agree to follow our Code of Conduct.

Describe the need

Users like @gr2m, @yermulnik and @dark-light-cz have run into problems using gh-copilot in #1 and #98 due to the use of personal access tokens. This is because gh-copilot has only supported the use of GitHub CLI OAuth app due to requirements of the Copilot platform.

This issue is track interest in extending support to personal access tokens.

Version

This affects all github/gh-copilot versions prior to v1.0.6 at the time of creating this issue.

Relevant terminal output

$ export GH_TOKEN="ghp_..."
$ gh copilot suggest

✗ Error: No valid GitHub CLI OAuth token detected

To get started with GitHub Copilot in the CLI, please run: gh auth login --web -h github.com to authenticate via web browser.

Activity

  1. yermulnik commented on Feb 13, 2025

    @yermulnik

    Just to bump this issue as of https://github.blog/changelog/2025-02-12-github-copilot-chat-and-github-copilot-extension-now-available-for-free-on-github-mobile-and-github-cli/ announcement: ain't gh-copilot should be capable of utilizing https://github.com/cli/go-gh (a collection of Go modules to make authoring GitHub CLI extensions easier) for auth to bring smoother experience to users? 🤔

    @andyfeller By any chance is this issue on a development roadmap please? 🙏🏻

  2. andyfeller commented on Feb 14, 2025

    @andyfeller
    ContributorAuthor

    Just to bump this issue as of https://github.blog/changelog/2025-02-12-github-copilot-chat-and-github-copilot-extension-now-available-for-free-on-github-mobile-and-github-cli/ announcement: ain't gh-copilot should be capable of utilizing https://github.com/cli/go-gh (a collection of Go modules to make authoring GitHub CLI extensions easier) for auth to bring smoother experience to users? 🤔

    @andyfeller By any chance is this issue on a development roadmap please? 🙏🏻

    Thanks for the bump, @yermulnik ❤

    The good news is gh-copilot has used cli/go-gh since its inception! ✊ The bad news is that PAT restriction is a larger Copilot authentication challenge beyond gh-copilot. That said, let me see about following up internally to see if there's any movement there.

    cc @RyanHecht

  3. yermulnik commented on Feb 14, 2025

    @yermulnik

    Ah, I see. Apologies my newbie mix up of the things =)
    And thanks for keeping this request rolling 👍🏻

  4. ascheman commented on Mar 14, 2025

    @ascheman

    I have run into the very same issue and would even consider the current behaviour as bug for two reasons

    • The error message does not tell you that the copilot plugin is using the PAT from the environment but cannot authenticate with it (-> better error message)
    • The plugin should simply ignore the PAT if it cannot use it for authentication (at most issue a warning).

    However, in the end, I'd be happy with both solutions, i.e., if either authentication via PAT would be possible, or if the PAT would be ignored by the plugin (falling back to the next level of authentication).

  5. magnusriga commented on Apr 23, 2025

    @magnusriga

    @andyfeller You asked in some other thread why people use a PAT in environment variables for gh. I just wanted to note that we add PAT to shell environment variable GH_TOKEN, because of a Neovim plugin that uses gh under the hood. Saves us having to authenticate with a browser, each time nvim is opened.

    Is there any way to keep that variable intact in the environment, and still access gh copilot? Perhaps setting another environment variable that takes precedence?

    Thanks for the help.

  6. jmarcon commented on May 7, 2025

    @jmarcon

    What I did to solve my problema in my use case was:

    • unset GITHUB_TOKEN and GH_TOKEN
    • authenticated with 'gh auth login --web -h github.com'
    • got the token with 'gh auth token -h githbu.com' (the token will start with "gho_")
    • set the GH_TOKEN with this value. (I did put this in my startup script - .zshrc/.bashrc and $PROFILE for PowerShell)
    • GH_TOKEN has precedence over GITHUB_TOKEN, so both can be set and the gh cli will use the GH_TOKEN.
    • Now I can use the cli and keep my GITHUB_TOKEN for use in other scenarios.

    I don't know if it is possible to use GITHUB_TOKEN with neovim's plugins.

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions