Skip to content

Commit

Permalink
feat: copilot AuthToken for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nathabonfim59 committed Dec 15, 2024
1 parent 9b63a4a commit 544f548
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions copilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ package main
import (
"encoding/json"
"os"
"path/filepath"
"runtime"
)

func getCopilotAuthToken() (string, error) {
// TODO: Windows?
bts, err := os.ReadFile(os.Getenv("HOME") + "/.config/github-copilot/hosts.json")
var sessionPath string
if runtime.GOOS == "windows" {
// C:\Users\user\AppData\Local\github-copilot\hosts.json
sessionPath = filepath.Join(os.Getenv("LOCALAPPDATA"), "github-copilot", "hosts.json")
} else {
// ~/.config/github-copilot/hosts.json
sessionPath = filepath.Join(os.Getenv("HOME"), ".config/github-copilot", "hosts.json")
}

bts, err := os.ReadFile(sessionPath)
if err != nil {
return "", err
}
Expand Down

0 comments on commit 544f548

Please sign in to comment.