DeepSeek Harness Plugin: qwen-sub-oauth

Introduction

In DeepSeek Harness (DSH), extending model providers through plugins is a common practice. When you need to connect a Qwen Plus/Pro subscription but don’t want to or can’t use an API Key, you’ll need a dedicated plugin to handle OAuth authentication.

Plugin Overview

zznobzz/dsh-qwen-sub-oauth is a DSH plugin that integrates the Qwen Plus/Pro subscription as a model provider into DeepSeek Harness. It completes authorization via the OAuth device flow, eliminating the need to hardcode an API Key in your configuration.

Installation & Activation

In a DSH configuration that already has the llm-pi-ai plugin installed (all built-in configurations include this plugin), run the following command to install:

dsh plugin --profile web add github:zznobzz/dsh-qwen-sub-oauth

The plugin is activated via hot module replacement (HMR) and generally does not require a configuration restart. If HMR is disabled on the host, simply restart the configuration once.

Usage Workflow

  1. First activation: The plugin initiates the OAuth device flow and outputs a link in the host console, similar to:
[qwen-sub-oauth] авторизация: https://chat.qwen.ai/authorize?user_code=XXXX-XXXX&client=cli (код XXXX-XXXX)
  1. Open the link in your browser, confirm you are logged in to chat.qwen.ai, and approve the device code.
  2. Wait for авторизация завершена to appear in the logs, or ask the assistant to display the current login link from the system prompt.
  3. Run /qwen-setup to register the provider route to llm-pi-ai. If auto-registration was rejected, this command will retry.
  4. Select “Qwen (подписка OAuth)” in the model selector and specify a model name, such as qwen3.8-max, qwen3.8-flash, or qwen4-max.

Common Commands

  • /qwen-login: Display the current pending verification link or initiate a new device flow.
  • /qwen-status: Check the authorization status and access token expiration.
  • /qwen-setup: Re-register the qwen-sub-oauth provider route.

Configuration

The default plugin configuration is as follows:

- insert:
    - id: qwen-sub-oauth
      name: dsh-qwen-sub-oauth
      config:
        autoLogin: true        # 激活时若未登录则启动设备流
        configureRoute: true   # 自动注册 llm-pi-ai 路由
        intervalMs: 600000     # 令牌刷新间隔(毫秒)

If you prefer to declare the route yourself, you can disable configureRoute and add the following block to your configuration 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

Authentication Flow

  • Device code: POST https://auth.qwen.ai/api/oauth/device/code, client_id=qwen-code-cli, scope="model:invoke profile:read"
  • User approval: https://chat.qwen.ai/authorize?user_code=…&client=cli
  • Token retrieval: POST https://auth.qwen.ai/api/oauth/token, grant_type=urn:ietf:params:oauth:grant-type:device_code
  • Token refresh: POST https://auth.qwen.ai/api/oauth/token, grant_type=refresh_token
  • User info: GET https://auth.qwen.ai/api/oauth/userinfo
  • Model invocation: POST https://api.qwen.ai/compatible-mode/v1/chat/completions with the header Authorization: Bearer <access_token>

Security & Notes

  • Tokens are stored exclusively in DSH’s credential store ($DSH_HOME/.credentials.yaml, permissions 0600) and are never written to configuration files.
  • client_id=qwen-code-cli is the public client identifier for Qwen Code CLI. Using its tokens from a third-party client falls into a gray area under Qwen’s terms of service; quotas follow your subscription plan.
  • Never send your Qwen account password or credentials to any “subscription proxy” service.
  • If invalid_grant appears during refresh, the refresh token has expired. Re-run /qwen-login and delete QWEN_SUB_OAUTH_REFRESH (if the plugin still considers you logged in).
  • Requests must carry a User-Agent in the format QwenCode/…; otherwise, Aliyun WAF will return a 405 with an HTML response.
  • The verification link points to the SPA route /authorize?user_code=…&client=cli. Do not use the /device URI returned by the Token endpoint (that URI does not exist in the deployed SPA).
  • If the provider does not appear in the model selector, run /qwen-setup. If a configuration error is reported, manually add the provider block or restart the configuration.

Uninstallation

dsh plugin --profile web remove dsh-qwen-sub-oauth

To clear stored credentials, delete QWEN_SUB_OAUTH_TOKEN and QWEN_SUB_OAUTH_REFRESH from the credential store.

Summary

This plugin provides DSH users with an OAuth-based authorization method for using the Qwen Plus/Pro subscription. Combined with automatic token refresh, it eliminates the need to manually manage an API Key, making it well-suited for scenarios where you need to leverage Qwen subscription capabilities within a local Harness.

  • Plugin directory: https://www.skillhub.cn/plugins/zznobzz/dsh-qwen-sub-oauth
  • GitHub: https://github.com/zznobzz/dsh-qwen-sub-oauth
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye