Authentication (OAuth)Introduction

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:

ModeGrant TypeWhen to Use
Open Modeauthorization_code + PKCEEnd-user authorization. The user logs in on the authorization page, selects a Space, and grants access.
Designated Space Modeauthorization_code + PKCE + space_idEnterprise scenario. The Space is pre-determined; use /members/add to pre-add users before initiating OAuth.
Server-to-Serverclient_credentialsBackend 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:

  1. Generate a PKCE code_verifier / code_challenge pair
  2. Open GET /openapi/v1/oauth/auth in a WebView — user logs in, selects Space, clicks Agree
  3. WebView redirects to your redirect_uri with an auth_code; intercept it
  4. Exchange the auth_code for access_token + refresh_token
  5. Use the access_token to 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

TokenTTLFlowsNotes
access_token1 hourBothJWT, stateless
refresh_tokenPermanentAuthorization Code onlyRolling 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 envelopes
  • envelope:read — Read envelope status and details
  • envelope:manage — Manage envelopes (create, send, download, view, etc.), superset of envelope:create + envelope:read, recommended for new integrations
  • stamp: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.)