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, for example: envelope:create envelope:read.
Currently supported scopes:
| Scope | Description |
|---|---|
envelope:create | Create and send envelopes |
envelope:read | Read envelope status and details |
envelope:sign | Interface Signing (sign on behalf of a specified recipient) |
envelope:manage | Envelope management; superset of envelope:create / envelope:read / envelope:sign |
stamp:manage | Manage stamps |
template:manage | Manage templates |
member:manage | Manage members (list, add, edit, enable/disable, remove members, and invite again) |
bill:manage | Billing and usage details |
- A token holding
envelope:managecan access every endpoint that requiresenvelope:create/envelope:read/envelope:sign; endpoints that requireenvelope:manage(signing links, void, remind, etc.) require anenvelope:managetoken.- The requested scopes must be a subset of the scopes granted to your app / installation (
granted_scopes); otherwise the token request returnsinvalid_scope.*is only used in an app’s / Space’s granted scopes to mean “all permissions” - do not request it when obtaining a token.