Introduction
Firstly, you need to subscribe to the two directories of server JSAPI authentication and non-login in enterprise application, and then complete the subsequent interface call for the entire JSAPI authentication process.
Access Process of JSAPI authentication
Getting application “access_token”
Interface name
Request method
POST
Parameter description
| Parameter | Parameter Type | Required | Remark |
|---|---|---|---|
| appkey | String | Yes | Application ak |
| appsecret | String | Yes | Application sk |
Return Description
{"success": true,"content": {"data": {"accessToken": "app_d81b204e64ce4244be0330dc4d3550bb"},"success": true,"requestId": "df04428415763208417945782d291f","responseMessage": "OK","responseCode": "0"}}
Getting application ticket
Interface name
Request Method
Parameter Description
| 参数 | 参数类型 | 必须 | 说明 |
|---|---|---|---|
| accessToken | String | 是 | 应用 access_token |
Return Description
{"success": true,"content": {"data": {"expiresIn": 4561,"accessToken": "jsApi_009dde783756450184e897b9e2943c71"},"success": true,"requestId": "df04428415763320830387621d291f","responseMessage": "OK","responseCode": "0"}}
JSAPI authorization
Note: h5 application in “my app”——> “application configuration”——> “web configuration”——>”mobile terminal link” must be filled in with the real h5 homepage address.
Interface Name
Interface Directory
API function description
For the call of some government-related and security-related JSAPIs, authentication is required before the call.
Parameter Description
| Parameter | Parameter Type | Description | Necessary |
|---|---|---|---|
| ticket | String | Ticket got from the background | Yes |
| jsApiList | Array | List of jsapi to be called | Yes |
Code example
dd.authConfig({ticket: "asdad",jsApiList:["alert","需要鉴权的jsapi方法名"]}).then(res =>{console.log(res)}).catch(err =>{})
Error Code
| Interface | Error Code | Error Description | Remark |
|---|---|---|---|
| validate_ticket | 0 | OK | 成功 |
| validate_ticket | 101001 | ticket, jsApiList cannot be empty | |
| validate_ticket | 101002 | ticket verification failed | |
| validate_ticket | 101003 | Application verification failed | |
| validate_ticket | 101004 | Application ID and ticket do not match | Application identifier and ticket do not match: You need to check whether the AK/SK and domain name are correct. The steps are as follows: 1. Check the AccessKey, SecretKey, and initialization parameters Whether DomainName is the that of the corresponding environment and the applied AK/SK; 2. The appkey and appsecret of /gettoken.json are also the AK/SK of the application, which is consistent with the initialization; 3. Check whether the actual access domain name is consistent with the homepage link configured in the application background. |
| validate_ticket | 101099 | Unknown error |
