Last Updated on : 2024-06-20 07:20:16download
This topic describes the related APIs of authorization management.
Request method | API | Description |
---|---|---|
GET | /v1.0/token | Get the access token. |
GET | /v1.0/token/{refresh_token} | Refresh the user token. |
POST | /v1.0/users/{uid}/ticket | Login-free token. |
Get the token by the authorized credential generated from a cloud application created on the Tuya Developer Platform.
GET /v1.0/token
Parameter | Type | Parameter type | Required | Description |
---|---|---|---|---|
grant_type | Integer | URL | Yes | Authorization type. 1: Simple mode. |
Parameter | Type | Description |
---|---|---|
code | Integer | Response code. See Error code. |
success | Boolean | Determine whether the request succeeded or not.
|
msg | String | The message returned if the request fails. If the request succeeds, null is returned. |
result | Object<result> | Token information. |
Description of result
Parameter | Type | Description |
---|---|---|
uid | String | Tuya user ID. |
access_token | String | Access token. |
refresh_token | String | Refresh token. |
expire | Integer | Valid period in seconds. |
GET /v1.0/token?grant_type=1
{
"success":true,
"result": {
"uid":"euxxxxxxxxx",
"access_token": "",
"expire_time": 7200,
"refresh_token": ""
}
}
The following are common service exceptions for this API. For more exception errors, see Error Code.
Error code | Description |
---|---|
500 | System error. |
1003 | Invalid grant type. |
1107 | Invalid code. |
The OAuth token
is currently valid for two hours for security concerns. After it has expired, you need to call refresh_token
to get a new token.
Note: The
access_token
has a validity period limit but no limit on the number of times. Therefresh_token
has no limit of the validity period but only takes effect once.
GET /v1.0/token/{refresh_token}
GET /v1.0/token/xxxxxx
{
"success":true,
"result": {
"uid":"euxxxxxxxxx",
"access_token": "",
"expire_time": 7200,
"refresh_token": ""
}
}
The following are common service exceptions for this API. For more exception errors, see Error Code.
Error code | Description |
---|---|
500 | System error. |
1003 | Invalid grant type. |
1107 | Invalid code. |
Generate a login-free token according to the Tuya user ID (UID). The token is used in certain scenarios or by some APIs.
POST /v1.0/users/{uid}/ticket
Parameter | Type | Parameter type | Required | Description |
---|---|---|---|---|
uid | String | URI | Yes | Tuya user ID. |
POST /v1.0/users/ay1541161424063AjySj/ticket
Parameter | Type | Description |
---|---|---|
code | Integer | Response code. See Error code. |
success | Boolean | Determine whether the request succeeded or not.
|
msg | String | The message returned if the request fails. If the request succeeds, null is returned. |
result | Object | Token information. |
{
"success":true,
"result":{
"ticket":"e0dcadc407806d0360a4df9f5b9f7942",
"expire_time":300
}
}
Error code | Description |
---|---|
500 | System error. |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback