Third-Party Authorization Management

Last Updated on : 2024-06-20 07:19:50download

Sequence diagram

Third-Party Authorization Management

Authorization process

  1. A third-party system server authorizes an account to access the Tuya Developer Platform and determines the type of the authorized account. It can be a user or staff account of the third-party system, or an account of any internal business form, such as an enterprise, store, or project.

  2. Get a ticket. The third-party system server sends the authorized account and country code to the Tuya Developer Platform, and requests a ticket.

  3. Get a session through the ticket.

    • Scenario 1: Add the ticket to the Tuya domain name to jump without login. For example, visit Tuya’s system website at lighting.console.tuyacn.com?ticket=xxxxx. Typical case: Scan a QR code to control devices.
    • Scenario 2: Tuya commercial lighting SDK gets the session interface, passes in the ticket to get the session status, and accesses the complete SDK capabilities.

API list

Request method API Description
POST /v1.0/industry/auth/admin The third-party system authorizes an account to access the Tuya Developer Platform.
POST /v1.0/industry/auth/ticket Get a ticket.
POST /v1.0/illumination/account/permission/add Grant project space permissions to the account.
GET /v1.0/illumination/account/list Get the list of authorized accounts.

Grant jump permissions to the staff accounts

API description

Authorize enterprise staff to log in to the Tuya SaaS Platform.

API endpoint

POST /v1.0/industry/auth/admin

Request parameter

Parameter Type Parameter type Description Required
username String body The account name. Yes
password String body The password. No
nickName String body The username. No
countryCode String body The country code. Default value: 86. No

Response parameter

Parameter Type Description
Code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: succeeded.
  • false: failed.
msg String The error message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

"ay1575258560846OO4lC"

Sample request

{
  "username": "123456",
  "nickName": "xxxx",
  "countryCode": "86"
  }

Sample response

{
   "success":"true",
   "t":1541071460239,
   "result":"ay1575258560846OO4lC"
}

Get a login ticket

API description

Get a ticket to log in to the Tuya SaaS Platform.

API endpoint

POST /v1.0/industry/auth/ticket

Request parameter

Parameter Type Parameter type Description Required
username String body The username. Yes
countryCode String body The country code. Default value: 86. No.

Response parameter

Parameter Type Description
Code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: succeeded.
  • false: failed.
msg String The error message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-digit timestamp.
result String The returned result.

Description of result

{
result:"12hjklgew2gtywgwxsdgw"
}

Sample request

{
  "username": "186xxxx2790",
  "countryCode":"86"
}

Sample response

{
    "success":true,
    "t":1541071460239,
    "result": "12hjklgew2gtywgwxsdgw"
}

Grant project space permission

API description

Grant project space permissions to a sub-account.

API endpoint

POST /v1.0/illumination/account/permission/add

Request parameter

Parameter Type Parameter type Description Required
projectId String body The project ID. Yes
tuyaUid String body Tuya user ID. Yes
roomIdList List body The list of space IDs. Yes

Response parameter

Parameter Type Description
Code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: succeeded.
  • false: failed.
msg String The error message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

{
  true/false
}

Sample request

{
  "tuyaUid": "ay1563*******1zJw30",
  "projectId": "123324234",
  "roomIdList": ["1420922162969059328"]
}

Sample response

{
    "success":true,
    "t":1541071460239,
    "result": true
}

Get the list of authorized accounts

API description

Get the list of authorized accounts.

API endpoint

GET /v1.0/illumination/account/list

Request parameter

Parameter Type Parameter type Description Required
loginName String body The login name. No
nickName String body The nickname. No
page int body The current page number. No
pageSize int body The number of items returned per page. No

Response parameter

Parameter Type Description
Code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: succeeded.
  • false: failed.
msg String The error message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

{
  "total": "int",
  "list": [
    {
      "uid": "String // The UID",
      "loginName": "String // The login name",
      "nickName": "String // The nickname",
      "roleCode": "String // The role code",
      "roleName": "String // The role name",
      "remark": "String // The remarks",
      "createDate": "String // The creation date",
      "adminId": "String // The account ID",
      "page": "int",
      "pageSize": "int"
    }
  ]
}

Sample request

{
  "loginName": "xxx",
}

Sample response

{
  "total": "int",
  "list": [
    {
      "uid": "xxxx",
      "loginName": "",
      "nickName": "",
      "roleCode": "",
      "roleName": "",
      "remark": "",
      "createDate": "",
      "adminId": "",
    }
  ]
}