{"id":47895181,"url":"https://github.com/bad-noodles/opencode-qwen-auth","last_synced_at":"2026-04-04T03:40:40.439Z","repository":{"id":342886708,"uuid":"1174919305","full_name":"bad-noodles/opencode-qwen-auth","owner":"bad-noodles","description":"OpenCode plugin — authenticate with Qwen via OAuth and use your free Qwen Code account instead of a paid API key","archived":false,"fork":false,"pushed_at":"2026-03-07T21:14:43.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-08T01:51:28.227Z","etag":null,"topics":["ai","alibaba","authentication","coding-assistant","developer-tools","free","llm","oauth","opencode","opencode-plugin","qwen","qwen-code"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bad-noodles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-07T01:46:34.000Z","updated_at":"2026-03-07T21:14:46.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bad-noodles/opencode-qwen-auth","commit_stats":null,"previous_names":["bad-noodles/opencode-qwen-auth"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/bad-noodles/opencode-qwen-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bad-noodles%2Fopencode-qwen-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bad-noodles%2Fopencode-qwen-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bad-noodles%2Fopencode-qwen-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bad-noodles%2Fopencode-qwen-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bad-noodles","download_url":"https://codeload.github.com/bad-noodles/opencode-qwen-auth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bad-noodles%2Fopencode-qwen-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31387023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T01:22:39.193Z","status":"online","status_checked_at":"2026-04-04T02:00:07.569Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","alibaba","authentication","coding-assistant","developer-tools","free","llm","oauth","opencode","opencode-plugin","qwen","qwen-code"],"created_at":"2026-04-04T03:40:38.377Z","updated_at":"2026-04-04T03:40:40.431Z","avatar_url":"https://github.com/bad-noodles.png","language":"JavaScript","readme":"# opencode-qwen-auth\n\n[![npm version](https://img.shields.io/npm/v/opencode-qwen-auth)](https://www.npmjs.com/package/opencode-qwen-auth)\n[![npm downloads](https://img.shields.io/npm/dm/opencode-qwen-auth)](https://www.npmjs.com/package/opencode-qwen-auth)\n[![license](https://img.shields.io/npm/l/opencode-qwen-auth)](./LICENSE)\n\n\u003e **Alpha software.** This plugin is early-stage and may have rough edges. Bug reports and feedback are welcome — please [open an issue](https://github.com/bad-noodles/opencode-qwen-auth/issues).\n\nOpenCode plugin that authenticates with Qwen via OAuth — use your free [Qwen Code](https://qwen.ai) account instead of a paid API key.\n\n\u003e **Caution:** This plugin relies on the same OAuth flow as the official Qwen Code CLI. Alibaba could restrict third-party access at any time. Use at your own discretion.\n\n## Prerequisites\n\n- A free account at [qwen.ai](https://qwen.ai) (the same one used by the `qwen` CLI)\n- No API key required\n\n## Free Quota\n\nThe Qwen Code account provides a generous free quota for the `qwen3-coder-plus` model. Exact limits may vary by account.\n\n## Setup\n\n1. Add the plugin to your `opencode.json`:\n\n```json\n{\n  \"$schema\": \"https://opencode.ai/config.json\",\n  \"plugin\": [\"opencode-qwen-auth\"],\n  \"provider\": {\n    \"qwen\": {\n      \"npm\": \"@ai-sdk/openai-compatible\",\n      \"name\": \"Qwen\",\n      \"options\": {\n        \"apiKey\": \"oauth\"\n      },\n      \"models\": {\n        \"qwen3-coder-plus\": {\n          \"name\": \"Qwen3 Coder Plus\",\n          \"tool_call\": true,\n          \"limit\": { \"context\": 1000000, \"output\": 65536 }\n        }\n      }\n    }\n  }\n}\n```\n\n2. Log in:\n\n```sh\nopencode auth login\n```\n\nSelect **Qwen** as the provider, then **Login with Qwen account**. Your browser will open automatically — approve the request and you're done.\n\n3. Select the model in OpenCode: `qwen / qwen3-coder-plus`\n\n## How it works\n\nThe plugin implements the same device code + PKCE OAuth flow used by the official `qwen` CLI. On each API request it:\n\n- Injects the Bearer token (auto-refreshed before expiry)\n- Sets the `X-DashScope-AuthType: qwen-oauth` header required by the backend\n- Resolves the base URL dynamically from the `resource_url` field in the token response\n- Injects a system message if the request lacks one (required to access Qwen Code quota — see [`REVERSE_ENGINEERING.md`](./REVERSE_ENGINEERING.md))\n- Retries token refresh with exponential backoff on transient failures\n- Coordinates refresh token rotation across multiple concurrent opencode sessions via a sidecar file (`~/.local/share/opencode/qwen-refresh.json`)\n\n## Updating\n\nOpenCode does not auto-update plugins. To get the latest version:\n\n```sh\nrm -rf ~/.cache/opencode/node_modules/opencode-qwen-auth\nopencode\n```\n\n## Troubleshooting\n\n### \"Refresh token expired or invalid. Please re-authenticate\"\n\nYour session has expired. Log in again:\n\n```sh\nopencode auth login\n```\n\nSelect **Qwen** → **Login with Qwen account**.\n\n### Getting a 429 / `insufficient_quota` error\n\nThis usually means the system message injection is not working. Ensure you are using the latest version of the plugin (see [Updating](#updating)).\n\n### The browser didn't open during login\n\nThe URL is always shown in the terminal as a fallback — copy and paste it into your browser manually.\n\n### The error only appears in one of several open opencode windows\n\nThis is a known cross-process token rotation issue. Closing and reopening the affected window usually resolves it. If it persists, re-authenticate as above.\n\n## FAQ\n\n**Does this work without a paid Qwen account?**\nYes. A free account at [qwen.ai](https://qwen.ai) is all you need.\n\n**Is my API key or password stored anywhere?**\nNo. The plugin uses OAuth — only short-lived access tokens and refresh tokens are stored by OpenCode in `~/.local/share/opencode/auth.json`. Your password never touches this plugin.\n\n**Which models are supported?**\n`qwen3-coder-plus` is the recommended model and is confirmed to work. Other model IDs may return errors — see [`REVERSE_ENGINEERING.md`](./REVERSE_ENGINEERING.md) for details.\n\n**Will this break if Alibaba updates the Qwen CLI?**\nPossibly. The plugin reverse-engineers the OAuth flow used by the official `qwen` CLI. If Alibaba changes the flow or revokes third-party client IDs, the plugin will stop working until updated.\n\n**Can I use this alongside a DashScope API key?**\nYes. The plugin also exposes an \"Enter DashScope API Key manually\" option in the auth flow.\n\n## Reporting issues\n\nRun the diagnostic script and include the output in your bug report:\n\n```sh\ncurl -fsSL https://raw.githubusercontent.com/bad-noodles/opencode-qwen-auth/main/diagnose.sh | sh\n```\n\nThen [open an issue](https://github.com/bad-noodles/opencode-qwen-auth/issues/new?template=bug_report.md). See [CONTRIBUTING.md](./CONTRIBUTING.md) for more details.\n\n## Local development\n\n```sh\ngit clone https://github.com/bad-noodles/opencode-qwen-auth.git\n```\n\nThen point your config at the local path:\n\n```json\n{\n  \"plugin\": [\"file:///absolute/path/to/opencode-qwen-auth\"]\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbad-noodles%2Fopencode-qwen-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbad-noodles%2Fopencode-qwen-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbad-noodles%2Fopencode-qwen-auth/lists"}