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, for example: envelope:create envelope:read.

Currently supported scopes:

ScopeDescription
envelope:createCreate and send envelopes
envelope:readRead envelope status and details
envelope:signInterface Signing (sign on behalf of a specified recipient)
envelope:manageEnvelope management; superset of envelope:create / envelope:read / envelope:sign
stamp:manageManage stamps
template:manageManage templates
member:manageManage members (list, add, edit, enable/disable, remove members, and invite again)
bill:manageBilling and usage details
  • A token holding envelope:manage can access every endpoint that requires envelope:create / envelope:read / envelope:sign; endpoints that require envelope:manage (signing links, void, remind, etc.) require an envelope:manage token.
  • The requested scopes must be a subset of the scopes granted to your app / installation (granted_scopes); otherwise the token request returns invalid_scope.
  • * is only used in an app’s / Space’s granted scopes to mean “all permissions” - do not request it when obtaining a token.