Authentication (OAuth)
Overview
Tencent eSign OAuth 2.0 Authorization Service provides secure API access for application integrations.
Two authorization modes are supported depending on your integration scenario:
| Mode | Grant Type | When to Use |
|---|---|---|
| Open Mode | authorization_code + PKCE | End-user authorization. The user logs in on the authorization page, selects a Space, and grants access. |
| Designated Space Mode | authorization_code + PKCE + space_id | Enterprise scenario. The Space is pre-determined; use /members/add to pre-add users before initiating OAuth. |
| Server-to-Server | client_credentials | Backend service calls on behalf of a Space. No user interaction required. |
Authorization Code Flow (PKCE)
Used for third-party integrations where end-user authorization is required.
Steps:
- Generate a PKCE
code_verifier/code_challengepair - Open
GET /openapi/v1/oauth/authin a WebView — user logs in, selects Space, clicks Agree - WebView redirects to your
redirect_uriwith anauth_code; intercept it - Exchange the
auth_codeforaccess_token+refresh_token - Use the
access_tokento call business APIs
redirect_uri: Supports custom schemes (e.g.
myapp://oauth-callback) and HTTPS URLs. HTTP (plain) is not accepted.
Client Credentials Flow
For server-to-server integration. No user interaction required.
Token Lifecycle
| Token | TTL | Flows | Notes |
|---|---|---|---|
| access_token | 1 hour | Both | JWT, stateless |
| refresh_token | Permanent | Authorization Code only | Rolling refresh — each use issues a new refresh_token and immediately invalidates the old one |
Scope Format
Scopes are space-separated strings: envelope:create envelope:read
Currently supported scopes:
envelope:create— Create and send envelopesenvelope:read— Read envelope status and detailsenvelope:manage— Manage envelopes (create, send, download, view, etc.), superset ofenvelope:create+envelope:read, recommended for new integrationsstamp:manage— Manage stamps (create, edit, delete, view, etc.)template:manage— Manage templates (create, edit, delete, use, etc.)member:manage— Manage members (pre-add, activate, etc.)