dsh-qwen-sub-oauth
Manifest validQwen Plus/Pro subscription as a DeepSeek Harness provider: OAuth device flow, automatic token rotation, no API key
dsh-qwen-sub-oauth
Use a Qwen Plus/Pro subscription (chat.qwen.ai) as a model provider in DeepSeek Harness — with OAuth, no API key.
The old free Qwen OAuth (chat.qwen.ai/api/v1/oauth2/*) was shut down on 2026-04-15. The subscription flow Qwen Code uses today is different, and this plugin speaks it: device flow against auth.qwen.ai, OpenAI-compatible gateway at api.qwen.ai/compatible-mode/v1, and automatic token rotation into the DSH credential store.
What it does
- Registers the provider route
qwen-sub-oauth(api.qwen.ai/compatible-mode/v1, modelsqwen3.8-max,qwen3.8-flash,qwen4-max, 1M context) inllm-pi-aithrough the DSH config editor. It tries on activation; if the host refuses the edit while the install transaction is still open,/qwen-setupcompletes it. - Starts the OAuth device flow on activation when no refresh token is stored yet, and prints the verification URL to the host console.
- While a sign-in is pending, relays the exact approval URL through a system-prompt section, so the assistant shows it verbatim in any chat. Commands:
/qwen-login(confirm the pending code or start a fresh flow),/qwen-status(token presence and expiry),/qwen-setup(register the route again if the automatic attempt was refused). The link is also logged to$DSH_HOME/qwen-sub-oauth.log. - Refreshes the access token before it expires and writes
QWEN_SUB_OAUTH_TOKEN/QWEN_SUB_OAUTH_REFRESHinto the credential store. LLM adapters re-read the reference per request, so rotation needs no restart.
Requirements
- A Qwen account with an active Plus or Pro subscription on chat.qwen.ai. OAuth alone grants no model access.
- DeepSeek Harness with the
llm-pi-aiplugin (every shipped profile has it) and the local credential store.
Install
dsh plugin --profile web add github:zznobzz/dsh-qwen-sub-oauth
The bundle activates live through HMR — no restart needed on a standard profile. (If your host runs with HMR disabled, restart the profile once.)
On first activation the plugin starts the device flow and logs a link such as:
[qwen-sub-oauth] авторизация: https://chat.qwen.ai/authorize?user_code=XXXX-XXXX&client=cli (код XXXX-XXXX)
Open it in a browser (you must already be signed in to chat.qwen.ai), approve the code, and wait for авторизация завершена in the log — or just ask the assistant to show the login link, it relays the live URL from its system prompt. Then run /qwen-setup to register the route. In the GUI, /qwen-login reprints the pending link or starts a new one, /qwen-status shows the current state.
Usage
Pick Qwen (подписка OAuth) in the model selector and choose qwen3.8-max, qwen3.8-flash or qwen4-max.
/qwen-login # pending verification link + code, or a fresh flow
/qwen-status # authorized? when does the access token expire?
/qwen-setup # add the provider route to llm-pi-ai again
Configuration
- insert:
- id: qwen-sub-oauth
name: dsh-qwen-sub-oauth
config:
autoLogin: true # start the device flow on activation when not signed in
configureRoute: true # register the pi-ai route when it is absent
intervalMs: 600000 # token refresh tick
If you prefer to declare the route yourself, disable configureRoute and add it to your profile patch:
- id: llm-pi-ai
name: "@deepseek-ai/dsh-llm-pi-ai"
config:
providers:
qwen-sub-oauth:
displayName: Qwen (OAuth subscription)
api: openai-completions
baseURL: https://api.qwen.ai/compatible-mode/v1
apiKeyEnv: QWEN_SUB_OAUTH_TOKEN
models:
- id: qwen3.8-max
name: Qwen3.8 Max
contextWindow: 1000000
maxTokens: 32768
How the flow works
| Step | Request |
|---|---|
| Device code | POST https://auth.qwen.ai/api/oauth/device/code — client_id=qwen-code-cli, scope="model:invoke profile:read" |
| User approves | https://chat.qwen.ai/authorize?user_code=…&client=cli (the advertised /device URI has no SPA route) |
| Token | POST https://auth.qwen.ai/api/oauth/token — grant_type=urn:ietf:params:oauth:grant-type:device_code |
| Refresh | POST https://auth.qwen.ai/api/oauth/token — grant_type=refresh_token |
| Profile | GET https://auth.qwen.ai/api/oauth/userinfo |
| Model calls | POST https://api.qwen.ai/compatible-mode/v1/chat/completions with Authorization: Bearer <access_token> |
A User-Agent of the QwenCode/… shape is mandatory: Aliyun WAF answers 405 and an HTML stub to default HTTP-client agents.
Troubleshooting
MISSING_CREDENTIAL/PROXY_TOKEN_MISSING— no token in the store: run/qwen-login.invalid_grantduring refresh — the refresh token was revoked: rerun/qwen-login(deleteQWEN_SUB_OAUTH_REFRESHfirst if the plugin still considers you signed in).405plus HTML instead of JSON — a request went out without theQwenCode/…User-Agent.- The verification link lands on the chat home page — use the
/authorizelink this plugin prints. ThedeviceURI that the token endpoint advertises has no route in the deployed SPA;/authorize?user_code=…&client=cliis what Qwen Code itself opens. - No route in the model selector — run
/qwen-setup; if it reports a configuration error, add the provider block manually or restart the profile.
Uninstall
dsh plugin --profile web remove dsh-qwen-sub-oauth
Remove the qwen-sub-oauth provider block from your profile patch and unset the stored credentials if you want the tokens gone.
Security and terms
- Tokens live only in the DSH credential store (
$DSH_HOME/.credentials.yaml, mode0600); nothing is written into configuration. client_id=qwen-code-cliis the public Qwen Code CLI client. Using its tokens from a third-party client is a grey area of Qwen's terms of service; quotas follow your subscription plan.- Never send your Qwen password or account credentials to any "subscription proxy" service. Revoke access by removing the stored tokens.
MIT licensed.
Comments
Loading…