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

Failed to authenticate 401 #697

Open
codeasashu opened this issue Dec 25, 2024 · 2 comments
Open

Failed to authenticate 401 #697

codeasashu opened this issue Dec 25, 2024 · 2 comments

Comments

@codeasashu
Copy link

I am having trouble using this plugin. I am using tag v3.3.3 of this plugin in neovim. On using any chat feature (such as quick reply), I am getting the error: "Failed to authenticate 401". Copilot is enabled in my github account.

image image

I tried adding some print to the curl_get function and this is the output:

15:00:14 msg_show Sending GET request to URL: https://api.github.com/copilot_internal/v2/token
15:00:14 msg_show  Request Options: {
15:00:14 msg_show  headers = {
15:00:14 msg_show    accept = "application/json",
15:00:14 msg_show    authorization = "token ghu_<hidden>",
15:00:14 msg_show    ["editor-plugin-version"] = "CopilotChat.nvim/2.0.0",
15:00:14 msg_show    ["editor-version"] = "Neovim/0.10.1",
15:00:14 msg_show    priority = "u=4, i",
15:00:14 msg_show    ["sec-fetch-dest"] = "empty",
15:00:14 msg_show    ["sec-fetch-mode"] = "no-cors",
15:00:14 msg_show    ["sec-fetch-site"] = "none",
15:00:14 msg_show    ["user-agent"] = "CopilotChat.nvim/2.0.0"
15:00:14 msg_show  },
15:00:14 msg_show  insecure = false,
15:00:14 msg_show  raw = { "--retry", "2", "--retry-delay", "1", "--keepalive-time", "60", "--no-compressed", "--connect-timeout", "10", "--tcp-nodelay", "--no-buffer" },
15:00:14 msg_show  timeout = 30000
15:00:14 msg_show }
15:00:15 msg_show Response Status: 401

15:00:15 msg_show Response Headers: { "date: Wed, 25 Dec 2024 09:30:15 GMT", "content-type: application/json; charset=utf-8", "content-length: 95", "x-github-media-type: github.v3", "x-ratelimit-limit: 60", "x-ratelimit-remaining: 55", "x-ratelimit-reset: 1735119715", "x-ratelimit-used: 5", "x-ratelimit-resource: core", "access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", "access-control-allow-origin: *", "strict-transport-security: max-age=31536000; includeSubdomains; preload", "x-frame-options: deny", "x-content-type-options: nosniff", "x-xss-protection: 0", "referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin", "content-security-policy: default-src 'none'", "vary: Accept-Encoding, Accept, X-Requested-With", "server: github.com", "x-github-request-id: D3DD:1D274C:18A09B:20FA91:676BD0A6", "", "" }

15:00:15 msg_show Response Body: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}

I tried making this request separately in terminal:

curl -H "authorization: token ghu_<hidden>" https://api.github.com/copilot_internal/v2/token

{"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}

However, it works when I use following header, this time with 404 error:

curl -H "authorization: ghu_<hidden>" https://api.github.com/copilot_internal/v2/token

{"message":"Not Found","documentation_url":"https://docs.github.com/rest","status":"404"}

I am having following 2 files in ~/.config/github-copilot dir:

  1. hosts.json
  2. versions.json

Content of hosts.json:

{
  "github.com": {
    "user": "codeasashu",
    "oauth_token": "ghu_<hidden>"
  }
}

Content of versions.json:

{"copilot.lua":"1.13.0"}

I doubt if https://api.github.com/copilot_internal/v2/token endpoint is even a valid REST endpoint?

@deathbeam
Copy link
Collaborator

It is valid endpoint otherwise the plugin would not work. Is copilot.vim (or copilot.lua) working for you?

@codeasashu
Copy link
Author

@deathbeam yes, copilot is working fine. Also tested with vscode, and it is working fine there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants