Authentication fails when running opencode auth login without prior qwen-code installation
Steps to Reproduce:
- Follow the current documentation
- Run
opencode auth login - Authentication fails
Suggestion: Add the following to the Prerequisites section:
npm install -g qwen-code
Then run the authentication command within qwen-code:
qwen-code auth login
Reason:
Users need to install and use the qwen-code package first to complete the authentication process. The opencode CLI depends on authentication tokens generated by qwen-code. Current documentation incorrectly assumes this prerequisite step.
Implementation Reference:
- User installs qwen-code globally:
npm install -g qwen-code - User completes authentication in qwen-code:
qwen-code auth login - qwen-code generates and stores authentication token locally
opencodeCLI can then access and use this token for API requests
Additional Context:
Without completing qwen-code authentication first, the opencode auth login command has no valid authentication context to work with. This is a documentation gap rather than a code issue.
Thanks for reporting this @xiaoyingv!
You're right that authentication was failing, but the root cause wasn't a missing qwen-code dependency — the plugin already has its own OAuth Device Flow (RFC 8628) built in. The real issues were bugs in the code plus dead code that caused confusion:
Bugs fixed in v1.3.0:
Bun.sleep()was used in the polling loop, which doesn't work on Node.js (replaced with standardsetTimeout)slow_downresponse from the server was silently swallowed instead of increasing the polling intervalrefreshToken || ''incorrectly treated empty string as falsy
Dead code removed:
- Fallback to
~/.qwen/oauth_creds.json(leftover from early development) - Unused functions, types, and files that referenced
qwen-code
How to authenticate (no qwen-code needed):
- Install/update the plugin:
npm install [email protected] - Run
opencode auth login - Select "Qwen Code (qwen.ai OAuth)"
- A browser window opens → sign in with your qwen.ai account
- Done!
Fixed in v1.3.0.