feat: Add Qwen OAuth authentication with QR code login support#822
feat: Add Qwen OAuth authentication with QR code login support#822kyeo-hub wants to merge 9 commits intosipeed:mainfrom
Conversation
- Add qwen_oauth.go for Qwen Portal OAuth device code flow - Use github.com/google/uuid instead of custom UUID generation - Add qwen_provider.go for Qwen OAuth LLM provider - Update auth helpers to support qwen provider login/logout - Update factory_provider.go to support qwen-oauth protocol - Update feishu_64.go to use Google uuid library Fixes reviewer comments about using Google uuid library instead of custom implementation. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> Add qwen-portal as an alternative protocol prefix for Qwen OAuth authentication
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> Add documentation for Qwen OAuth (QR code login) in both README.md and README.zh.md
Code Review: Qwen OAuth AuthenticationThanks for this contribution! The overall implementation looks solid. Here are my findings: ✅ What's Done Well
🔴 Critical Issues1. helpers.go:204-220 - Forcefully Overwrites User Configuration```go Problem: If a user has already configured a custom qwen model (e.g., `qwen/qwen-max`), it will be forcibly changed to `coder-model` after login. Suggestion: Only update `AuthMethod` and credential-related fields, preserve the original model configuration. 2. helpers.go:224 - Silently Modifies Default Model```go Problem: After login, the user's default model is automatically changed to qwen-coder without consent. This is too aggressive. 🟡 Medium Issues3. qwen_oauth.go:354, 384, 528 - HTTP Client Created Repeatedly```go Suggestion: Reuse HTTP client, or use `sync.Once` for lazy initialization. 4. qwen_oauth.go:577-580 - Refresh Failure Silently Ignored```go Problem: No logging when refresh fails, users won't know their token is about to expire. 5. qwen_provider.go:716-717 - Repeated TrimPrefix Calls```go Could be simplified or extracted to a utility function. 6. Code Duplication - `convertMessagesForQwen` and `convertToolsForQwen`These functions are nearly identical to implementations in other providers (OpenAI, DeepSeek). Consider extracting to a common module. 🟢 Minor Issues7. qwen_oauth.go:589-595 - Unused Parameter```go If `verifyURL` isn't used, don't pass it as a parameter. 8. helpers.go:181-186 - Incomplete `isQwenModel` Check```go Missing the `qwen-portal` alias which is supported in `factory_provider.go`. 🔧 Suggested Fixes```go // Remove this line - don't change default model without consent 📊 Summary
Recommendation: Fix the two critical issues (forced configuration overwrite) before merging. Other issues can be addressed in follow-up PRs. |
- Fix gci formatting: remove trailing whitespace on line 230 - Add nolint:gosmopolitan for intentional Chinese UI strings - Remove unused qwenPortalBaseURL constant - Fix spelling: serialises → serializes Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
95c9674 to
4c96503
Compare
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Add qwen_oauth_test.go with 17 test cases for OAuth authentication - Add qwen_provider_test.go with 15 test cases for Qwen provider - Fix factory_provider.go to separate qwen and qwen-oauth protocols - Add qwen API key and OAuth examples to config.example.json - Export SetQwenTestEndpoints for testability This addresses PR review feedback: 1. ✅ Add test files for CI automation 2. ✅ Fix configuration and documentation consistency Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Review: Qwen OAuth Authentication ImplementationThanks for this comprehensive feature addition! The implementation is well-structured with good test coverage (32 test cases). Here are my observations: ✅ Strengths
|
| Category | Assessment |
|---|---|
| Feature Completeness | ✅ Complete |
| Security | ✅ PKCE correctly implemented |
| Code Quality | ✅ Good |
| Test Coverage | ✅ Comprehensive |
| Documentation | ✅ Complete |
Recommendation: Address the cancellable polling issue, then this PR is ready to merge. Great work!
📝 Description
What this PR does
Implements Qwen OAuth authentication using the device code flow (QR code scan), allowing users to authenticate with their Qwen/Alibaba Cloud account without manually managing API keys.
Key features
https://portal.qwen.ai/v1/chat/completionsendpointqwen-oauth,qwenoauth,qwen-portalcoder-model(Qwen Coder for code generation and understanding)Configuration example
Usage
Documentation
Commits
d1f105afeat: add Qwen OAuth authentication with UUID library53306c5refactor: revert unnecessary uuid change in feishu_64.godca090afeat: add qwen-portal alias for Qwen OAuth provideref9a14adocs: add Qwen OAuth configuration guide