Project Authorization Mode
The project authorization model is suitable for B-side projects in various industries, such as digital transformation or intelligent upgrade of hotels, offices, schools and other projects.
- Project: refers to the project created through the Aqara IoT Solution Platform, and the user can bind the devices to the project through the provided implementation tool.
The sequence diagram of the authorization process is shown below.
Step 1 Get authorization verification code
- Register and log in to Aqara IOT Solution Platform;
- Create a project, select the project that needs to be authorized-Extension service page;
- Obtain the authorization verification code.
Step 2 Obtain the accessToken through the authorization verification code
- API intent: config.auth.getToken
- Description: Before the authorization code expires, obtain the accessToken through the authorization code. The default validity period of the access token is 7 days.
- Request parameters
Name |
Type |
Is required? |
Description |
authCode |
String |
Yes |
The authCode requested in the previous step |
accountType |
Integer |
No |
Account Type, 1- project authorization |
{
"intent": "config.auth.getToken",
"data": {
"authCode": "xxxx",
"accountType": 1
}
}
Name |
Type |
Description |
expiresIn |
String |
The remaining valid time of the access token, the unit is s. |
openId |
String |
Authorized user's unique identifier |
accessToken |
String |
Access token |
refreshToken |
String |
Refresh token, the validity period of refreshToken is the access token’s expiration date plus 30 days. |
{
"code": 0,
"requestId": "",
"message": "Success",
"msgDetails": null,
"result": {
"expiresIn": "86400",
"openId": "593652793976837702248177061889",
"accessToken": "b8001e1893f5e4316a4f8c3b47df3720",
"refreshToken": "ddd9dc7e9ec7b772e852121ed2fe75aa"
}
}
Step 3 Refresh the accessToken through refreshToken to obtain new accessToken and refreshToken
- API intent: config.auth.refreshToken
- Description: Before the accessToken expires, refresh the access token with refreshToken through this interface. The refreshToken duration defaults to the period of accessToken + 30 days.
- Request parameters
Name |
Type |
Is required? |
Description |
refreshToken |
String |
Yes |
Refresh token |
{
"intent": "config.auth.refreshToken",
"data": {
"refreshToken": "xxxx"
}
}
Name |
Type |
Description |
expiresIn |
String |
The remaining valid time of the access token, the unit is s. |
openId |
String |
Authorized user's unique identifier |
accessToken |
String |
New access token |
refreshToken |
String |
New refresh token |
{
"code": 0,
"requestId": "",
"message": "Success",
"msgDetails": null,
"result": {
"expiresIn": "86400",
"openId": "593652793976837702248177061889",
"accessToken": "b8001e1893f5e4316a4f8c3b47df3720",
"refreshToken": "ddd9dc7e9ec7b772e852121ed2fe75aa"
}
}