Skip to content

oauth.accessToken ​

This interface is implemented on the platform application (APP) server side and called by the SUD OpenPaaS server.

Obtain the access token (access_token).

Call method:

  • HTTPS call

HTTPS Call ​

http
POST {access_token_webhook}

Request Parameters - Header ​

FieldTypeDefaultRequiredDescription
timestamplongYesMillisecond timestamp, follows the common anti-replay rules
noncestringYesRandom string of up to 32 characters, follows the common anti-replay rules
signstringYesRSA-SHA256 signature, follows the common signing rules
client_secretstringYesApplication secret assigned by the platform application (APP) to SUD (application-level authentication secret, passed only in the Header)

Request Parameters - Body ​

FieldTypeDefaultRequiredDescription
client_idstringYesApplication ID assigned by the platform application (APP) to SUD
grant_typestringYesFixed value: authorization_code (authorization code mode)
codestringYesThe authorization code obtained from the oauth.authorize interface
redirect_uristringYesCallback address, must exactly match the address provided when requesting the authorization code

Return Value ​

Object ​

The returned JSON data packet

FieldTypeDescription
ret_codeintegerResponse code: 0 means success, non-0 means failure
ret_msgstringResponse description: returns "success" on success, returns the specific error reason on failure
dataobjectBusiness data body (valid data returned only when ret_code=0)
data.access_tokenstringAccess token issued by the platform application (APP); subsequent game/vendor data pull interfaces must carry this token for authentication
data.refresh_tokenstringRefresh token, used to obtain a new token after the access_token expires (validity is longer than that of the access_token)
data.expires_inintegeraccess_token validity (unit: seconds), default 7200 seconds (2 hours), subject to the interface return value
data.token_typestringToken type, fixed as Bearer
data.scopestringAuthorized scopes (e.g. read write)

Vendor identity is not returned in the token response: parse it from the access_token claim (e.g. JWT uid), or call cp.queryDetail and use data.id for account mapping.

Valid Values of ret_code ​

ValueDescriptionMinimum Version
0Request succeeded
40029invalid code, the authorization code is invalid or expired
40030invalid sign, check the signing algorithm and whether the public/private keys match
40101client_secret mismatch, check whether the secret in the Header is correct

cURL Request ​

bash
curl -X POST \
  {access_token_webhook} \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'timestamp: 1668512806000' \
  -H 'nonce: abcdef1234567890' \
  -H 'sign: YOUR_RSA_SIGNATURE' \
  -H 'client_secret: YOUR_CLIENT_SECRET' \
  -d '{
  "client_id": "YOUR_CLIENT_ID",
  "grant_type": "authorization_code",
  "code": "YOUR_AUTH_CODE",
  "redirect_uri": "https://your.domain.com/callback"
}'

Success Response ​

json
{ 
  "ret_code": 0,
  "ret_msg": "success",
  "data": {
    "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
    "token_type": "Bearer",
    "expires_in": 7200,
    "refresh_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
    "scope": "read write"
  }
}

Error Response ​

json
{
  "ret_code": 40029,
  "ret_msg": "invalid code"
}