Alipay Mini Program authorizes to obtain user token
SDK apifmDevelopment reference
First, you need to call the login API of the mini program to obtain the temporary credential code:
[https://opendocs.alipay.com/mini/api/openapi-authorize?pathHash=22642781](https://opendocs.alipay.com/mini/api/openapi-authorize?pathHash=22642781)
After obtaining the code, you can directly authorize login and obtain the user's login token with one click:
```javascript
WXAPI.aliappUserAuthorize({
code: 'dsdfdgrert35567878987989'
})
```
Of course, you can also pass in more parameters as follows:
+ postJsonString Custom extended attributes in json format, the changed data will be saved when the user authorizes (registers) for the first time;
+ referrer The user number of the inviter. After this parameter is passed in, the system will automatically record the user's invitation relationship, and this relationship will be used in subsequent distribution and team structures;An example data for postJsonString is as follows:
```json
{
"School": "Zhejiang University",
"Professional": "Computer"
}
```
Interface return example:
```json
{
"code": 0,
"data": {
"uid": 1394134,
"openid": "ocpiX1vggFL0FojVNh0CB6RfrwWQ",
"aliUserId": 12333333,
"token": "b220f152-b12c-483e-a146-0eec75b2cde3"
},
"msg": "success"
}
```
The interface will return to you the user number, token, and the openid aliUserId of the user.