GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Fix GitHub Copilot authentication flow by bitomule · Pull Request #294 · opencode-ai/opencode
This repository was archived by the owner on Sep 18, 2025. It is now read-only.
ConversationSummaryThis PR fixes the GitHub Copilot authentication flow in OpenCode, which currently has issues with token retrieval and exchange. Problem DescriptionCurrently, the GitHub Copilot integration has several issues:
SolutionThis PR implements a complete authentication flow inspired by the one used in the Neovim Copilot plugin:
DocumentationAdded comprehensive documentation to the README explaining:
This PR makes Copilot integration work seamlessly with OpenCode, especially important for users wanting to access Claude models through Copilot.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Implement a simplified 4-step authentication flow: 1. Check if Copilot is enabled in config 2. Check for token in config folder 3. If no token, trigger login flow 4. With token ready, open OpenCode normally Key improvements: - Cleaner code structure with helper functions - Better error handling for auth scenarios - Support for both hosts.json and apps.json formats - Proper API version headers for GitHub Copilot - Clear documentation of client ID usage - Remove redundant checks for Copilot provider in Validate() - Improve comments for better clarity - Maintain the same functionality with cleaner code - Simplify logging in GitHub Copilot authentication - Remove redundant logging messages - Remove unused getMapKeys helper function - Keep only essential user feedback during authentication - Implement device flow authentication for GitHub Copilot - Add token saving to standard ~/.config/github-copilot/hosts.json - Fix token validation and error handling - Continue polling when receiving empty responses - Set environment variables for immediate use of token - Clean and simplify code implementation - Remove redundant token saving functions - Combine hosts.json handling in a single function - Simplify environment variable checks - Remove excessive debug logging - Streamline error handling and code paths
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid conflicts with other tools like the GitHub CLI (gh) that uses
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
|
I tested your PR but ran into this error:
This happens because my GITHUB_TOKEN is being rejected by Copilot. This creates a frustrating workflow for anyone who relies on that token for other tools. We shouldn't have to unset an important variable just to open opencode. So Like I said before we need to move away from If we do this we can fix #294 Thank you so much for the effort =) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…PILOT_TOKEN Address the issue where GITHUB_TOKEN conflicts with GitHub CLI tools by: - Prioritizing GITHUB_COPILOT_TOKEN environment variable over GITHUB_TOKEN - Updating token loading logic to avoid CLI token conflicts - Modifying error messages to reference the correct token variable - Updating documentation to reflect the new token preference This resolves 401 Unauthorized errors when users have standard GitHub tokens without Copilot scope. 🤖 Generated with opencode Co-Authored-By: opencode <[email protected]>
|
Hey @mendesbarreto pushed a new commit with your feedback. Is this what you had in mind? Thank you for your comments! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
It's working =) fixes #270 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
What's the next step to get it merged? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I have been following the tale of Copilot since its conception, and the last one who approved something similar was @kujtimiihoxha. 😊 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@bitomule I think the why is here: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hey guys, really sorry for the slow reply here. I am in the middle of a huge refactor and rebrand for opencode, would love it if you guys submit the early access form so you get to try the new version earlier https://charm.sh/early-access |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
subscribed ✅ !!!!!!!!!!! Thank you so much @kujtimiihoxha |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.