GetOpenId/GetPhoneNumber/GetEmailAddress
Workflow#
- The mini app calls the js api
bn.getOpenId()
orbn.getPhoneNumber()
orbn.getEmailAddress
to the mini program framework, the later will popup a authorization page for the user to approve, and return the data_token if the user approves - The mini app uploads the data_tokee=n to the merchant’s backend
- The backend calls the getOpenData with the data_token , and get the data from response
- The backend decrypt the data, get openid or phone number or email address
You can get all the required APIs in the reference. This API only works only Binance APP >= 2.51.0
Preparation#
Please refer to Preparation Of Open Service
Mini Program#
On the mini program, the developer can call the js api: bn.getOpenId()
or bn.getPhoneNumber()
or bn.getEmailAddress()
to pop-up an authorization page for the user. After getting the user’s approval, the api will return the data_token`, which can be used to fetch the openid or phone number or email address of the user on the backend.
Backend#
Backend#
Host: dip-cb.binanceapi.com
GET /mp-api/v1/apps/{appId}/user-open-data?openData=data_token
Parameters
Parameter | Description |
---|---|
appId | required appId of the mini program |
openData | required data_token from previous steps |
Note:
1. data_token Only valid for 2 minutes
2. You need to call this api by carrying a jwt token in the header X-Mp-Open-Api-Token
. For the method of generating JWT token, please refer to Description of External Interface Signature Authentication Algorithm
Request
Response
HTTP 200
ErrorCode | Remark |
---|---|
000000 | Success |
900001 | Invalid Param |
900002 | Jwt auth failed |
900003 | Unexpected error |
900200 | Data token expired |
900201 | Invalid data token |