opencode-qwencode-auth icon indicating copy to clipboard operation
opencode-qwencode-auth copied to clipboard

Authentication fails when running opencode auth login without prior qwen-code installation

Open xiaoyingv opened this issue 9 months ago • 1 comments

Steps to Reproduce:

  1. Follow the current documentation
  2. Run opencode auth login
  3. 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:

  1. User installs qwen-code globally: npm install -g qwen-code
  2. User completes authentication in qwen-code: qwen-code auth login
  3. qwen-code generates and stores authentication token locally
  4. opencode CLI 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.

xiaoyingv avatar Feb 12 '26 02:02 xiaoyingv

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 standard setTimeout)
  • slow_down response from the server was silently swallowed instead of increasing the polling interval
  • refreshToken || '' 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):

  1. Install/update the plugin: npm install [email protected]
  2. Run opencode auth login
  3. Select "Qwen Code (qwen.ai OAuth)"
  4. A browser window opens → sign in with your qwen.ai account
  5. Done!

Fixed in v1.3.0.

gustavodiasdev avatar Feb 12 '26 20:02 gustavodiasdev