Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lua/codecompanion/adapters/http/copilot/stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ local function get_statistics()

local oauth_token = token.fetch().oauth_token

local endpoint = string.format("https://api.%s/copilot_internal/user", vim.env.GH_HOST or "github.com")
local ok, response = pcall(function()
return Curl.get("https://api.github.com/copilot_internal/user", {
return Curl.get(endpoint, {
sync = true,
headers = {
Authorization = "Bearer " .. oauth_token,
Expand Down
5 changes: 3 additions & 2 deletions lua/codecompanion/adapters/http/copilot/token.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ local function get_oauth_token()

userdata = vim.json.decode(userdata)
for key, value in pairs(userdata) do
if string.find(key, "github.com") then
if string.find(key, vim.env.GH_HOST or "github.com") then
return value.oauth_token
end
end
Expand Down Expand Up @@ -136,8 +136,9 @@ local function get_copilot_token()
_token_fetch_in_progress = true
log:trace("Authorizing GitHub Copilot token")

local endpoint = string.format("https://api.%s/copilot_internal/v2/token", vim.env.GH_HOST or "github.com")
local ok, request = pcall(function()
return Curl.get("https://api.github.com/copilot_internal/v2/token", {
return Curl.get(endpoint, {
headers = {
Authorization = "Bearer " .. (M._oauth_token or ""),
Accept = "application/json",
Expand Down