Skip to content

Conversation

@konard
Copy link
Contributor

@konard konard commented Dec 9, 2025

Summary

Comprehensive research on OAuth implementations across CLI agentic tools to inform Qwen OAuth integration for @link-assistant/agent.

Research Findings

  • Qwen Code CLI: Uses Device Code OAuth flow (~/.qwen/oauth_creds.json)
  • Claude Code: Uses PKCE OAuth with Anthropic (macOS Keychain / ~/.claude/)
  • Gemini CLI: Uses Google OAuth with web-based and user-code flows (~/.gemini/oauth_creds.json)
  • OpenCode: Plugin-based auth system supporting multiple providers (~/.opencode/auth.json)

Key Qwen OAuth Details

Parameter Value
Base URL https://chat.qwen.ai
Device Code Endpoint /api/v1/oauth2/device/code
Token Endpoint /api/v1/oauth2/token
Client ID f0304373b74a44d2b584a3fb70ca9e56
Scope openid profile email model.completion

Implementation Proposal

Recommended: Hybrid Phased Approach

Phase 1 (Immediate):

  1. Implement credential reading from ~/.qwen/oauth_creds.json
  2. Add QWEN_ACCESS_TOKEN environment variable support
  3. Document how to use existing Qwen Code CLI for login

Phase 2 (Full Implementation):

  1. Implement Device Code OAuth flow
  2. Add agent qwen:login command
  3. Support credential storage in ~/.agent/qwen/
  4. Implement token refresh logic

Phase 3 (Advanced):

  1. Consider plugin architecture for extensibility
  2. Add keychain storage option
  3. Support enterprise Qwen deployments

Documentation

See docs/QWEN_OAUTH_RESEARCH.md for the full research document including:

  • Complete OAuth flow diagrams
  • Credential storage locations comparison
  • Code implementation examples
  • Reference links to source code

Test Plan

  • Review research document for completeness
  • Validate Qwen OAuth endpoints are accurate
  • Verify credential storage paths match Qwen Code CLI
  • Consider edge cases (expired tokens, non-interactive environments)

References

Fixes #24


🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #24
@konard konard self-assigned this Dec 9, 2025
Research findings comparing OAuth implementations across CLI agentic tools:
- Qwen Code CLI: Device Code OAuth flow with qwen.ai
- Claude Code: PKCE OAuth with Anthropic
- Gemini CLI: Google OAuth with web-based and user-code flows
- OpenCode: Plugin-based auth system supporting multiple providers

Includes implementation proposals for @link-assistant/agent:
- Option 1: Full Device Code OAuth implementation
- Option 2: Credential reading only (minimal)
- Option 3: Plugin-style architecture
- Recommended: Hybrid phased approach

Documents credential storage locations for compatibility:
- Primary: ~/.qwen/oauth_creds.json (Qwen Code CLI)
- Fallback: ~/.agent/qwen/ (our app folder)

Closes research phase of #24

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Qwen Coder oAuth support Research: Qwen Coder OAuth support Dec 9, 2025
@konard konard marked this pull request as ready for review December 9, 2025 04:53
@konard
Copy link
Contributor Author

konard commented Dec 9, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $4.272865 USD
  • Calculated by Anthropic: $3.669694 USD
  • Difference: $-0.603171 (-14.12%)
    📎 Log file uploaded as GitHub Gist (558KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Qwen Coder oAuth support

2 participants