feat(dingtalk): add QR code scan authorization for setup wizard#9610
feat(dingtalk): add QR code scan authorization for setup wizard#9610audanye-sudo wants to merge 1 commit into
Conversation
Implement DingTalk device-flow registration that allows users to configure the DingTalk platform by scanning a QR code with their DingTalk app instead of manually copying Client ID and Client Secret from the developer console. New module hermes_cli/dingtalk_auth.py implements the 3-step registration flow (init → begin → poll) with terminal QR code rendering. The setup wizard in hermes_cli/gateway.py now offers QR scan as the recommended method with manual input as fallback. Also adds DINGTALK env var auto-detection in gateway/config.py for consistency with other platforms.
|
I need this func! |
|
Last one of the DingTalk trilogy (#9608, #9609, this one). The first two fix blocking bugs; this one improves the setup experience. The problem with current DingTalk setupRight now, configuring DingTalk in
This is a 5+ step manual process through a Chinese-language developer portal. For non-Chinese speakers it's basically impossible without a tutorial. Even for Chinese users, it's tedious and error-prone — wrong credentials, forgetting to enable robot capability, etc. Compare this to how other DingTalk ecosystem tools handle it: they use a QR code scan flow (similar to OAuth device flow). You scan a code with your DingTalk app, tap "authorize," and you're done. Credentials are obtained automatically. What this PR addsA QR code scan option in the setup wizard: Option 0 renders a QR code right in the terminal. Scan it with DingTalk, approve, and the Client ID + Secret are automatically fetched and saved. The whole thing takes about 10 seconds vs. the 5-minute manual flow. If the QR flow fails for any reason (no internet, user cancels, library missing), it gracefully falls back to manual input. No dead ends. Relationship to the other two PRsThis PR is independent of the bug fixes in #9608 and #9609. You can merge them in any order. But obviously, all three together give users the best experience: easy setup (this PR) + actually working message handling (#9608 + #9609). |
RuckVibeCodes
left a comment
There was a problem hiding this comment.
[gus-first-pass] feat(dingtalk): add QR code scan authorization for setup wizard - Clear feature addition, no issues found.
|
Closing — your QR auth PR ships the same three-step device flow as #8345 (meng93, submitted Apr 12 — before this PR), which has now been merged via salvage PR #11574 (#11574). Credit goes to meng93 as the original author since their submission was first and the implementations are line-for-line identical. Thanks for your effort and the independent validation of the approach. |
Summary
Adds a QR code scan authorization flow to the DingTalk setup wizard (
hermes gateway setup), eliminating the need for users to manually navigate the DingTalk Developer Console to obtain Client ID and Client Secret. This dramatically simplifies DingTalk onboarding — from a multi-step developer console workflow to a single QR scan.Motivation
Currently, configuring DingTalk requires users to:
This is error-prone (wrong credentials, missing robot capability) and intimidating for non-developer users. Other DingTalk ecosystem tools (e.g., dingtalk-openclaw-connector) already support device-flow registration — this PR brings parity.
How It Works
The implementation follows the DingTalk device-flow registration protocol (same as OAuth device flow):
User Experience
When running
hermes gateway setupand selecting DingTalk:Changes
hermes_cli/dingtalk_auth.pyhermes_cli/gateway.pygateway/config.pyDINGTALK_CLIENT_ID/DINGTALK_CLIENT_SECRETenv var auto-detection (parity with Feishu/Telegram/Discord)Design Decisions
qrcodeis not installed, the module triesuv pip installthenpip installautomatically. Falls back to showing the plain URL if install fails.expires_indefault. Polling interval respects the server-suggested value (minimum 2s).Commits
feat(dingtalk): add QR code scan authorization for setup wizardhermes_cli/dingtalk_auth.py,hermes_cli/gateway.py,gateway/config.pyTest Plan
.envuv pip, renders QR successfullyDINGTALK_CLIENT_IDdetected → prompts "Reconfigure?" → respects choicegateway/config.pyenv var detection:DINGTALK_CLIENT_ID+DINGTALK_CLIENT_SECRETin env → platform auto-enabledDINGTALK_HOME_CHANNELenv var →HomeChannelcorrectly configuredRisk Assessment
Low risk — purely additive feature:
_setup_standard_platformas before)dingtalk_auth.pyis only imported when user selects QR scangateway/config.pychange adds env var detection that was previously missing (all other platforms already had this)qrcodeis optional, auto-installed only when needed)Dependencies: This feature is independent of the stream adapter fix PRs and can be merged in any order.