Access Control

Last Updated on : 2023-06-01 10:37:36download

Access control of app users

Query a list of app users authorized for access

API description

fun fetchAppAccessList(
        ownerId: String,
        effective: Int,
        pageNo: String,
        pageSize: String,
        listener: Business.ResultListener<AccessPageBean>?
    )

Parameters

Parameter Description
ownerId The site ID.
effective
  • 0: The authorization is invalid.
  • 1: The authorization is valid.
pageNo The page number, starting from 1.
pageSize The number of entries to be returned per page. Default value: 20.

Example

TuyaSmartResidenceSdk.access()
                .fetchAppAccessList(ownerId, 1, "1", "20", object : Business.ResultListener<AccessPageBean> {
                    override fun onFailure(p0: BusinessResponse?, p1: AccessPageBean?, p2: String?) {
                                                //error callback
                    }

                    override fun onSuccess(p0: BusinessResponse?, p1: AccessPageBean?, p2: String?) {
                                                //success callback
                    }
                })

Add an app user allowed for access

API description

fun addAppAccess(accessCreateBean: AccessCreateBean, listener: Business.ResultListener<Boolean>?)

Parameters

Parameter Description
accessCreateBean The information about access control for app users.
username The username.
nickname The nickname.
deviceIdList The list of device IDs.
startTime The start time for the validity period of the authorization.
endTime The end time for the validity period of the authorization.
userType The type of member. Valid values:
  • 20: the administrator of the site
  • 30: an app user allowed for access
ownerId The site ID.

For access control sites and business-authorized sites, only app users whose userType is 30 can be created.

Example

TuyaSmartResidenceSdk.access().addAppAccess(accessCreateBean, object : Business.ResultListener<Boolean> {
        override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                //error callback
        }

        override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                //success callback
        }
})

Determine registered account

API description

fun checkAccessAccount(username: String, listener: Business.ResultListener<Boolean>?)

Parameters

Parameter Description
username The username.

Example

TuyaSmartResidenceSdk.access().checkAccessAccount(username, object : Business.ResultListener<Boolean> {
        override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                // error callback
        }

        override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                // success callback
        }
})

Determine authorized account

API description

fun checkAccessAuthorization(ownerId: String, username: String, listener: Business.ResultListener<Int>?)

Parameters

Parameter Description
ownerId The site ID.
username The username.

Example

TuyaSmartResidenceSdk.access().checkAccessAuthorization(ownerId,username,object : Business.ResultListener<Int> {
        override fun onFailure(p0: BusinessResponse?, p1: Int?, p2: String?) {
                // error callback
        }

        override fun onSuccess(p0: BusinessResponse?, p1: Int?, p2: String?) {
                // success callback
        }

})

Query details of an app user allowed for access

API description

fun fetchAppAccessUserDetail(
        ownerId: String,
        accessUserId: String,
        listener: Business.ResultListener<AccessBean>?
    )

Parameters

Parameter Description
ownerId The site ID.
accessUserId The member ID.

Example

TuyaSmartResidenceSdk.access().fetchAppAccessUserDetail(ownerId, accessUserId,
                object : Business.ResultListener<AccessBean> {
                        override fun onFailure(p0: BusinessResponse?, p1: AccessBean?, p2: String?) {
                                // error callback
                        }

                        override fun onSuccess(p0: BusinessResponse?, p1: AccessBean?, p2: String?) {
                                // success callback
                        }

})

Query access records of app users

API description

fun fetchAppAccessPassRecord(
        ownerId: String,
        accessUserId: String,
        pageNo: String,
        pageSize: String,
        listener: Business.ResultListener<PassRecordPageBean>?
    )

Parameters

Parameter Description
ownerId The site ID.
accessUserId The member ID.
pageNo The page number, starting from 1.
pageSize The number of entries to be returned per page. Default value: 20.

Example

TuyaSmartResidenceSdk.access().fetchAppAccessPassRecord(ownerId,accessUserId,"1","20",
                    object : Business.ResultListener<PassRecordPageBean> {
                    override fun onFailure(p0: BusinessResponse?, p1: PassRecordPageBean?, p2: String?) {
                                                        // error callback
                    }

                    override fun onSuccess(p0: BusinessResponse?, p1: PassRecordPageBean?, p2: String?) {
                                                        // success callback
                    }

                })

Query the total number of app users allowed for access

API description

fun fetchAppAccessTotal(ownerId: String, effective: Int, listener: Business.ResultListener<Int>?)

Parameters

Parameter Description
ownerId The site ID.
effective
  • 0: The authorization is invalid.
  • 1: The authorization is valid.

Example

TuyaSmartResidenceSdk.access().fetchAppAccessTotal(ownerId, 1, object : Business.ResultListener<Int> {
        override fun onFailure(p0: BusinessResponse?, p1: Int?, p2: String?) {
                // error callback
        }

        override fun onSuccess(p0: BusinessResponse?, p1: Int?, p2: String?) {
                // success callback
        }

})

Remove an app user allowed for access

API description

fun removeAppAccess(ownerId: String, accessUserId: String, listener: Business.ResultListener<Boolean>?)

Parameters

Parameter Description
ownerId The site ID.
accessUserId The member ID.

Example

TuyaSmartResidenceSdk.access().removeAppAccess(ownerId, accessUserId,
         object : Business.ResultListener<Boolean> {
                override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                         // error callback
                }

                override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                         // success callback
                }

            })

Modify an app user allowed for access

API description

fun updateAppAccess(access: AccessUser,listener: Business.ResultListener<Boolean>?)

Parameters

Parameter Description
access The information about access control for app users.
nickname The nickname.
deviceIdList The list of device IDs.
startTime The start time for the validity period of the authorization.
endTime The end time for the validity period of the authorization.
userType The type of member. Valid values:
  • 20: the administrator of the site
  • 30: an app user allowed for access
ownerId The site ID.
accessUserId The member ID.

Example

TuyaSmartResidenceSdk.access().updateAppAccess(accessUser, object : Business.ResultListener<Boolean> {
                override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                                // error callback
                }

                override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                                // success callback
                }

})

Bulk add devices accessible to an app user

API description

fun addAppAccessDevice(
        ownerId: String,
        accessUserId: String,
        deviceIdList: List<String>,
        listener: Business.ResultListener<Boolean>?
    )

Parameters

Parameter Description
ownerId The site ID.
accessUserId The member ID.
deviceIdList The list of device IDs.

Example

TuyaSmartResidenceSdk.access().addAppAccessDevice(ownerId,accessUserId, deviceIdList,
        object : Business.ResultListener<Boolean> {
                override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                       // error callback
                }

                override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                       // success callback
                }

       })

Remove a device from an app user

API description

fun removeAppAccessDevice(
        ownerId: String,
        accessUserId: String,
        deviceId: String,
        listener: Business.ResultListener<Boolean>?
    )

Parameters

Parameter Description
ownerId The site ID.
accessUserId The member ID.
deviceId The device ID.

Example

TuyaSmartResidenceSdk.access().removeAppAccessDevice(ownerId, accessUserId, deviceId,
        object : Business.ResultListener<Boolean> {
               override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                       // error callback
               }

               override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                       // success callback
               }
        })

Access control with passwords

Query a list of users allowed for access with passwords

API description

fun fetchPasswordAccessList(
        ownerId: String,
        effective: Int,
        pageNo: String,
        pageSize: String,
        listener: Business.ResultListener<ArrayList<AccessPasswordBean>>?
    )

Parameters

Parameter Description
ownerId The site ID.
effective
  • 0: The authorization is invalid.
  • 1: The authorization is valid.
pageNo The page number, starting from 1.
pageSize The number of entries to be returned per page. Default value: 20.

Example

TuyaSmartResidenceSdk.access().fetchPasswordAccessList(ownerId,1,"1","20",
                object : Business.ResultListener<ArrayList<AccessPasswordBean>> {
                override fun onFailure(p0: BusinessResponse?, p1: ArrayList<AccessPasswordBean>?, p2: String?) {
                                                // error callback
                }

                override fun onSuccess(p0: BusinessResponse?, p1: ArrayList<AccessPasswordBean>?, p2: String?) {
                                                // success callback
                }
                })

Add a member allowed for access with a password

API description

fun addPasswordAccess(
        ownerId: String,
        passwordCreateBean: PasswordCreateBean,
        deviceDataList: List<DeviceData>,
        listener: Business.ResultListener<PasswordResult>?
    )

Parameters

Parameter Description
ownerId The site ID.
passwordCreateBean The information about access control with passwords.
deviceDataList The list of device information.

Example

TuyaSmartResidenceSdk.access().addPasswordAccess(ownerId,passwordCreateBean,deviceDataList,
         object : Business.ResultListener<PasswordResult> {
                 override fun onFailure(p0: BusinessResponse?, p1: PasswordResult?, p2: String?) {
                         // error callback
                 }

                 override fun onSuccess(p0: BusinessResponse?, p1: PasswordResult?, p2: String?) {
                         // success callback
                 }
         })

Query details of a user allowed for access with a password

API description

fun fetchPasswordAccessUserDetail(
        ownerId: String,
        authGroupId: String,
        listener: Business.ResultListener<PasswordDetail>?
    )

Parameters

Parameter Description
ownerId The site ID.
authGroupId The member ID.

Example

TuyaSmartResidenceSdk.access().fetchPasswordAccessUserDetail(ownerId,authGroupId,
         object : Business.ResultListener<PasswordDetail> {
                    override fun onFailure(p0: BusinessResponse?, p1: PasswordDetail?, p2: String?) {
                            // error callback
                    }

                    override fun onSuccess(p0: BusinessResponse?, p1: PasswordDetail?, p2: String?) {
                            // error callback
                    }
         })

Query password access records of users

API description

fun fetchPasswordAccessPassRecord(
        ownerId: String,
        authGroupId: String,
        pageNo: String,
        pageSize: String,
        listener: Business.ResultListener<PassRecordPageBean>?
    )

Parameters

Parameter Description
ownerId The site ID.
authGroupId The member ID.
pageNo The page number, starting from 1.
pageSize The number of entries to be returned per page. Default value: 20.

Example

TuyaSmartResidenceSdk.access().fetchPasswordAccessPassRecord(ownerId,authGroupId,"1","20",
         object : Business.ResultListener<PassRecordPageBean> {
                 override fun onFailure(p0: BusinessResponse?, p1: PassRecordPageBean?, p2: String?) {
                         // error callback
                 }

                 override fun onSuccess(p0: BusinessResponse?, p1: PassRecordPageBean?, p2: String?) {
                         // success callback
                 }

         })

Query total number of users allowed for access with passwords

API description

fun fetchPasswordAccessTotal(ownerId: String, effective: Int, listener: Business.ResultListener<Int>?)

Parameters

Parameter Description
ownerId The site ID.
effective
  • 0: The authorization is invalid.
  • 1: The authorization is valid.

Example

TuyaSmartResidenceSdk.access().fetchPasswordAccessTotal(ownerId, 1, object : Business.ResultListener<Int> {
        override fun onFailure(p0: BusinessResponse?, p1: Int?, p2: String?) {
                // error callback
        }

        override fun onSuccess(p0: BusinessResponse?, p1: Int?, p2: String?) {
                // success callback
        }

})

Remove a user allowed for access with a password

API description

fun removePasswordAccess(ownerId: String, authGroupId: String, listener: Business.ResultListener<Boolean>?)

Parameters

Parameter Description
ownerId The site ID.
authGroupId The member ID.

Example

TuyaSmartResidenceSdk.access().removePasswordAccess(ownerId, authGroupId,
         object : Business.ResultListener<Boolean> {
                override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                         // error callback
                }

                override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                         // success callback
                }

            })

Update the nickname of a user allowed for access with a password

API description

fun updatePasswordAccessNickname(
        ownerId: String,
        authGroupId: String,
        nickname: String,
        listener: Business.ResultListener<Boolean>?
    )

Parameters

Parameter Description
ownerId The site ID.
authGroupId The member ID.
nickname The nickname.

Example

TuyaSmartResidenceSdk.access().updateAppAccess(accessUser, object : Business.ResultListener<Boolean> {
                override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                                // error callback
                }

                override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                                // success callback
                }

})

Change password validity

API description

fun updatePasswordAccessValidity(
        ownerId: String,
        authGroupId: String,
        doorPassword: DoorPassword,
        listener: Business.ResultListener<Boolean>?
    )

Parameters

Parameter Description
ownerId The site ID.
authGroupId The member ID.
doorPassword The information about the validity of the access control password.

Example

TuyaSmartResidenceSdk.access().updatePasswordAccessValidity(ownerId, authGroupId, doorPassword,
         object : Business.ResultListener<Boolean> {
                 override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                                                // error callback
                 }

                 override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                                                // success callback
                 }
         })

Bulk add devices accessible to a user with a password

API description

fun addPasswordAccessDevice(
        ownerId: String,
        authGroupId: String,
        deviceIdList: List<String>,
        listener: Business.ResultListener<Boolean>?
    )

Parameters

Parameter Description
ownerId The site ID.
authGroupId The member ID.
deviceIdList The list of device IDs.

Example

TuyaSmartResidenceSdk.access().addPasswordAccessDevice(ownerId, authGroupId, deviceIdList,
         object : Business.ResultListener<Boolean> {
                 override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                                                // error callback
                 }

                 override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                                                // success callback
                 }
         })

Remove devices from users allowed for access with passwords

API description

fun removePasswordAccessDevice(
        ownerId: String,
        authGroupId: String,
        deviceId: String,
        listener: Business.ResultListener<Boolean>?,
    )

Parameters

Parameter Description
ownerId The site ID.
authGroupId The member ID.
deviceId The device ID.

Example

TuyaSmartResidenceSdk.access().removePasswordAccessDevice(ownerId, authGroupId, deviceId,
        object : Business.ResultListener<Boolean> {
               override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                       // error callback
               }

               override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
                       // success callback
               }
        })

Query a list of access control devices

API description

fun fetchDeviceListWithSiteId(ownerId: String, listener: Business.ResultListener<ArrayList<String>>?)

Parameters

Parameter Description
ownerId The site ID.

Example

TuyaSmartResidenceSdk.access()
                .fetchDeviceListWithSiteId(ownerId, object : Business.ResultListener<ArrayList<String>> {
                    override fun onFailure(p0: BusinessResponse?, p1: ArrayList<String>?, p2: String?) {
                                                // error callback
                    }

                    override fun onSuccess(p0: BusinessResponse?, p1: ArrayList<String>?, p2: String?) {
                                                // success callback
                    }

                })