DingTalk Device Flow Auth (hermes_cli/dingtalk_auth.py)

atomic-hermes · hermes_cli/dingtalk_auth.py · python · MIT
auth, pos, lang:python, tag:dingtalk

Implements DingTalk device flow authorization with terminal QR code rendering. Reuse when authenticating via DingTalk.

# Source: https://github.com/AtomicBot-ai/atomic-hermes | License: MIT | Copyright 2025 Nous Research
# Provided via justclaw.it.com; keep this notice with the code.
"""
DingTalk Device Flow authorization.

Implements the same 3-step registration flow as dingtalk-openclaw-connector:
  1. POST /app/registration/init   → get nonce
  2. POST /app/registration/begin  → get device_code + verification_uri_complete
  3. POST /app/registration/poll   → poll until SUCCESS → get client_id + client_secret

The verification_uri_complete is rendered as a QR code in the terminal so the
user can scan it with DingTalk to authorize, yielding AppKey + AppSecret
automatically.
"""

from __future__ import annotations

import io
import os
import sys
import time
import logging
from typing import Optional, Tuple

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key