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
| Field | Type | Default | Required | Description |
|---|---|---|---|---|
| timestamp | long | Yes | Millisecond timestamp, follows the common anti-replay rules | |
| nonce | string | Yes | Random string of up to 32 characters, follows the common anti-replay rules | |
| sign | string | Yes | RSA-SHA256 signature, follows the common signing rules | |
| client_secret | string | Yes | Application secret assigned by the platform application (APP) to SUD (application-level authentication secret, passed only in the Header) |
Request Parameters - Body
| Field | Type | Default | Required | Description |
|---|---|---|---|---|
| client_id | string | Yes | Application ID assigned by the platform application (APP) to SUD | |
| grant_type | string | Yes | Fixed value: authorization_code (authorization code mode) | |
| code | string | Yes | The authorization code obtained from the oauth.authorize interface | |
| redirect_uri | string | Yes | Callback address, must exactly match the address provided when requesting the authorization code |
Return Value
Object
The returned JSON data packet
| Field | Type | Description |
|---|---|---|
| ret_code | integer | Response code: 0 means success, non-0 means failure |
| ret_msg | string | Response description: returns "success" on success, returns the specific error reason on failure |
| data | object | Business data body (valid data returned only when ret_code=0) |
| data.access_token | string | Access token issued by the platform application (APP); subsequent game/vendor data pull interfaces must carry this token for authentication |
| data.refresh_token | string | Refresh token, used to obtain a new token after the access_token expires (validity is longer than that of the access_token) |
| data.expires_in | integer | access_token validity (unit: seconds), default 7200 seconds (2 hours), subject to the interface return value |
| data.token_type | string | Token type, fixed as Bearer |
| data.scope | string | Authorized 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 usedata.idfor account mapping.
Valid Values of ret_code
| Value | Description | Minimum Version |
|---|---|---|
| 0 | Request succeeded | |
| 40029 | invalid code, the authorization code is invalid or expired | |
| 40030 | invalid sign, check the signing algorithm and whether the public/private keys match | |
| 40101 | client_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"
}