APP Server-Side Development
Get API Access Credential API
| Item | Example |
|---|---|
| Request URL | https://{domain}/api/oap/oauth/token |
| Request Method | POST |
Request Parameters
| Parameter | Description |
|---|---|
| grant_type | Fixed value client_credentials, OAuth client credentials mode |
| client_id | client_id assigned by the API provider |
| client_secret | client_secret assigned by the API provider |
Request Example
json
{
"grant_type": "client_credentials",
"client_id": "ZUSQzclVGYF",
"client_secret": "fnH5one7AmxPbl6ky6VHuFBNYQ88vAdvu0"
}Response Parameters
| Parameter | Reference |
|---|---|
| access_token | Access credential |
| token_type | Token type |
| expires_in | Validity period |
| scope | OAuth 2.0 scope |
| id_token | Permission information in JWT format |
Response Example
json
{
"access_token": "f7a815eb-c546-4052-b099-b554de1436c7",
"token_type": "bearer",
"expires_in": 764,
"scope": "all",
"id_token": "eyJraWQiOiJrMSIsImFsZyI6IlJTMjU2In0.eyJpc3MiOiJJc3N1ZXIiLC"
}Exchange for ssoTicket API
| Item | Interface URL |
|---|---|
| Request URL | /api/oap/v1/SSO/session_ticket |
| Request Method | POST |
Request Parameters
| Parameter Name | Description | Required | Example Value |
|---|---|---|---|
| sessionToken | sessionToken is valid for up to 30 days and is used to exchange for ssoTicket | Yes | r5ysOPTCBLU1 |
| operatingSysVersion | Requester User-Agent | Yes | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 |
| device_ip | Terminal device IP | Yes | 192.168.1.1 |
| device_fingerprint | Terminal device fingerprint (uniquely identifies the device) | Yes | qaws12fr45mjy7 |
Request Example
json
{
"sessionToken": "NPb1iZc11TKmgiefSYWrFnvT2DBhFPIX",
"operatingSysVersion": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36",
"device_ip": "121.60.119.225",
"device_fingerprint": "156aysdna213sc"
}Response Parameters
| Property Name | Sub-property | Parameter Description |
|---|---|---|
| code | Return code. Success: 0 | |
| message | Return message (records the failure reason when failed) | |
| data | expire | Remaining validity time of ssoTicket, in seconds |
| ssoTicket | ssoTicket (used to obtain user information during in-app mini-program SSO) |
Response Example
json
{
"code": "0",
"message": "success",
"data": {
"expire": 299,
"ssoTicket": "ssoTicket-p2WBMUCXaOGSQDzzMPYdqLvKvZcAe0yC"
}
}Validate ssoTicket API
| Item | Interface URL |
|---|---|
| Request URL | /api/oap/v1/SSO/session_ticket-validate |
| Request Method | POST |
Request Parameters
| Parameter Name | Description | Required | Example Value |
|---|---|---|---|
| ssoTicket | SSO ticket, valid for 300 seconds | Yes | ssoTicket-p2WBM |
| operatingSysVersion | Requester User-Agent | Yes | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 |
| device_ip | Terminal device IP | Yes | 192.168.1.1 |
| device_fingerprint | Terminal device fingerprint (uniquely identifies the device) | Yes | qaws12fr45mjy7 |
Request Example
json
{
"ssoTicket": "ssoTicket-7Ddh7KhsBKBgPuN82IVHZVDc6DPm8Jxh",
"operatingSysVersion": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36",
"device_ip": "121.60.119.225",
"device_fingerprint": "156aysdna213sc"
}Response Parameters
| Property Name | Sub-property | Parameter Description |
|---|---|---|
| code | Return code. Success: 0 | |
| message | Return message (records the failure reason when failed) | |
| data | userInfo | User information |
Response Example
json
{
"code": "0",
"message": "success",
"data": {
"userInfo": {
"id": "20201119181527383-7B3B-0571E338A",
"name": "lx4321",
"userName": "lx4321",
"mobile": "15907154321",
"email": "1014321@qq.com",
"age": 18,
"gender": 0,
"nick_name": "lxx",
"head_url": "https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKLb4AJez",
"realStatus": "PERSONAL",
"join_date": "2020-11-19T10:15:27.000Z"
}
}
}Refresh sessionToken API
| Item | Interface URL |
|---|---|
| Request URL | /api/oap/v1/SSO/refreshSessionToken |
| Request Method | POST |
Request Parameters
| Parameter Name | Description | Required | Example Value |
|---|---|---|---|
| sessionToken | Original sessionToken used to exchange for a new sessionToken | Yes | Mkkp1xSB4Wqj3 |
| operatingSysVersion | Requester User-Agent | Yes | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212Safari/537.36 |
| device_ip | Terminal device IP | Yes | 192.168.1.1 |
| device_fingerprint | Terminal device fingerprint (uniquely identifies the device) | Yes | qaws12fr45mjy7 |
Request Example
json
{
"sessionToken": "Yst40OUIo7zghBH3pFEniuSINGbLHzU3",
"operatingSysVersion": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 90.0 .4430 .212 Safari / 537.36 ",
"device_ip ": "121.60 .119 .225 ",
"device_fingerprint": "156aysdna213sc"
}Response Parameters
| Property Name | Sub-property | Parameter Description |
|---|---|---|
| code | Return code. Success: 0 | |
| message | Return message (records the failure reason when failed) | |
| data | sessionToken | Session token |
Response Example
json
{
"code": "0",
"message": "success",
"data": {
"sessionToken": "lqIprZxbyUelLbn5Yos33o8TeVnoZJFH"
}
}Session Persistence
The sessionToken expiration time is configurable (see the Access Token validity period configuration). To maintain login status, the APP server is advised to refresh and synchronize the token proactively.
It is recommended to call the refresh API one day or three days before the sessionToken is about to expire, ensuring the sessionToken is always valid.
The above is only a suggestion; the caller can set the refresh time according to actual business scenarios.