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

image.png

Getting application “access_token”

Interface name

/gettoken.json

Request method

POST

Example of call interface

Parameter description

Parameter Parameter Type Required Remark
appkey String Yes Application ak
appsecret String Yes Application sk

Return Description

  1. {
  2. "success": true,
  3. "content": {
  4. "data": {
  5. "accessToken": "app_d81b204e64ce4244be0330dc4d3550bb"
  6. },
  7. "success": true,
  8. "requestId": "df04428415763208417945782d291f",
  9. "responseMessage": "OK",
  10. "responseCode": "0"
  11. }
  12. }

Getting application ticket

Interface name

/get_jsapi_token.json

Request Method

POST

Parameter Description

参数 参数类型 必须 说明
accessToken String 应用 access_token

Return Description

  1. {
  2. "success": true,
  3. "content": {
  4. "data": {
  5. "expiresIn": 4561,
  6. "accessToken": "jsApi_009dde783756450184e897b9e2943c71"
  7. },
  8. "success": true,
  9. "requestId": "df04428415763320830387621d291f",
  10. "responseMessage": "OK",
  11. "responseCode": "0"
  12. }
  13. }

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

authConfig

Interface Directory

Device

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

  1. dd.authConfig({
  2. ticket: "asdad",
  3. jsApiList:["alert","需要鉴权的jsapi方法名"]
  4. }).then(res =>{
  5. console.log(res)
  6. }).
  7. 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