-
Notifications
You must be signed in to change notification settings - Fork 158
feat(copilot): adds github copilot login support #469
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
base: main
Are you sure you want to change the base?
feat(copilot): adds github copilot login support #469
Conversation
- Add full token exchange flow for GitHub Copilot auth - Store OAuth tokens in config directory - Register application in versions.json - Fix API endpoint URLs and request formatting
This give the user some time to open the browser and proceed with the login workflow.
|
||
// Add/update our entry | ||
// TODO: How can we import this? Create a `meta.go`? | ||
//versions["mods"] = main.Version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's no longer a single package, we can't access the Versions
variable. What would be the best approach here?
Alternatively, we can ditch the "app registration" entirely. This will be only used by Microsoft to track how many users of a given application are using Copilot. But we're not sending this info in the request, so it could be removed without a big impact.
I wonder if we could use https://github.com/cli/oauth for this - or parts of it? |
Thanks for the feedback! Using the I've done this "by hand" to avoid adding extra dependencies, but I can switch to using this library if you're comfortable with it. I guess it would be useful for future MCP and other AI providers that also uses the same method as well. |
I think it's probably fine to use it, yes 🙏 |
As mentioned in #426, currently, we require an external program to generate the Github Copilot oAuthToken.
This PR adds all necessary structures to do this first login within mods.
How to test
~/.config/github-copilot
)PR Summary
Authentication Refactor:
copilot.go
).CopilotDeviceCodeResponse
,CopilotDeviceTokenResponse
,CopilotFailedRequestResponse
,copilotGithubOAuthTokenWrapper
,copilotOAuthToken
) (copilot.go
).New Functions:
copilotLogin
function to initiate device code authentication and fetch the OAuth token (copilot.go
).fetchCopilotRefreshToken
function to poll for the OAuth token using the device code (copilot.go
).saveCopilotOAuthToken
andcopilotRegisterApp
functions to save the OAuth token and register the app version (copilot.go
).Refactoring Existing Functions:
getCopilotRefreshToken
to use the newcopilotLogin
function for obtaining the OAuth token (copilot.go
).getCopilotAccessToken
to fetch the OAuth token instead of the refresh token (copilot.go
).