Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: GitHub Copilot NOT WORKING with GH CLI #78

Closed
ffalkenberg opened this issue May 24, 2024 · 3 comments
Closed

[BUG]: GitHub Copilot NOT WORKING with GH CLI #78

ffalkenberg opened this issue May 24, 2024 · 3 comments
Labels
bug Something isn't working needs-triage needs to be reviewed

Comments

@ffalkenberg
Copy link

ffalkenberg commented May 24, 2024

Related Issue:

This issue appears to be related to GitHub issue #1.

Description:

I am unable to use GitHub Copilot with the CLI despite successfully logging in to my GitHub Copilot Business assigned account. The authentication process appears to complete, but attempting to use gh copilot commands results in an error indicating no valid OAuth token is detected. We are using an OAuth token, not a Personal Access Token (PAT).

  1. Set debug mode and authenticate with GitHub:

    GH_DEBUG=1 gh auth login --web -h github.com

    Output:

    ? What is your preferred protocol for Git operations on this host? HTTPS
    [git config credential.https://github.com.helper]
    [git config credential.helper]
    ? Authenticate Git with your GitHub credentials? Yes
    
    * Request at 2024-05-24 16:42:13.438777861 +0000 UTC m=+2.554865065
    * Request to https://github.com/login/device/code
    * Using proxy: <company-proxy>
    * Request took 236.735793ms
    ! First copy your one-time code: ...
    Press Enter to open github.com in your browser... 
    * Request at 2024-05-24 16:42:23.335165974 +0000 UTC m=+12.451253177
    * Request to https://github.com/login/oauth/access_token
    * Using proxy: <company-proxy>
    * Request took 153.079748ms
    * Request at 2024-05-24 16:42:28.49216627 +0000 UTC m=+17.608253476
    * Request to https://github.com/login/oauth/access_token
    * Using proxy: <company-proxy>
    * Request took 216.292382ms
    * Request at 2024-05-24 16:42:28.708593745 +0000 UTC m=+17.824680952
    * Request to https://api.github.com/graphql
    * Request took 304.10115ms
    ✓ Authentication complete.
    - gh config set -h github.com git_protocol https
    ✓ Configured git protocol
    ! Authentication credentials saved in plain text
    [git credential reject]
    [git credential approve]
    ✓ Logged in as <user>
    
  2. Verify authentication status:

    gh auth status

    Output:

    github.com
      ✓ Logged in to github.com account <user> (/home/user/.config/gh/hosts.yml)
      - Active account: true
      - Git operations protocol: https
      - Token: gho_************************************
      - Token scopes: 'gist', 'read:org', 'repo', 'workflow'
    
  3. Confirm token validity with an API call:

    curl -H "Authorization: token gho_<token>" https://api.github.com/user

    Output:

    {
        ...
        "name": "<user>",
        ...
    }
  4. Attempt to use GitHub Copilot in CLI:

    GH_DEBUG=1 gh copilot explain "sudo apt-get"

    Output:

    * Request at 2024-05-24 16:51:34.133665211 +0000 UTC m=+0.200250187
    * Request to https://api.githubcopilot.com/github/chat/threads
    * Request took 308.46323ms
    
    ✗ 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.
    

Expected Behavior:

GitHub Copilot should operate correctly, utilizing the authenticated session.

Environment:

  • GitHub CLI version: 2.49.2 (2024-05-14)
  • GitHub Copilot version: 1.0.3 (2024-05-08)
  • OS: CENTOS
  • Proxy: <company-proxy>

Additional Information:

The authentication process completes without error, and the token appears valid as verified by gh auth status and direct API calls using the token. However, the gh copilot commands fail to recognize the OAuth token.

image

@ffalkenberg ffalkenberg added bug Something isn't working needs-triage needs to be reviewed labels May 24, 2024
@mxie
Copy link

mxie commented May 24, 2024

I'm sorry to hear you're having issues, @ffalkenberg!

If you look further down on your Copilot settings page, you should see whether or not the feature itself was enabled by your org admin. It'd look something like this:
CleanShot 2024-05-24 at 13 40 12@2x

Can you confirm whether this is the case for you?

@ffalkenberg
Copy link
Author

@mxie Thank you such much for your support! We've resolved the issue!

Although we enabled the CLI, the error persisted. The root cause was the company proxy configuration. Setting the correct proxy resolved the problem:

HTTPS_PROXY=<dedicated-proxy> gh copilot explain "sudo apt-get"

The error message we received was quite misleading (No valid GitHub CLI OAuth token) and could benefit from improvement to help users diagnose proxy-related issues more effectively

@itsrohitsaroha
Copy link

itsrohitsaroha commented Jun 17, 2024

@mxie I am having a similar issue
While doing
GH_DEBUG=1 gh auth login

Request to https://api.github.com/graphql

Is not using proxy(all other requests are using proxy), just like the output pasted by @ffalkenberg at start. Because of this my org firewall blocks the request and I am not able to login.

Could you or anyone help me in this case? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage needs to be reviewed
Projects
None yet
Development

No branches or pull requests

3 participants