Authentication Method

Last Updated on : 2024-06-13 08:21:51download

A token is required to authenticate and authorize API calls. The cloud APIs comply with the OAuth 2.0 implicit authorization.

Simple mode

Third Party CloudTuya CloudGet an accesstoken.1. Get access_tokenwith client_id and client_secret.1.1 Return access_token.Service call.2. Make a service call.2.1 Return the operation result.Third Party CloudTuya CloudGet Access Token with Simple Mode

Applicability

The simple mode applies to access to data created by or associated with a cloud project.

Get access token

GET:/v1.0/token?grant_type=1

Data sources and API permissions

Data source API permission
The PID associated with the cloud project PID permission package
The mobile app or WeChat mini program associated with the cloud project Mobile app/WeChat Mini Program permission package
The user associated with the cloud project User permission package

OAuth 2.0

UserThird Party App/BrowserThird Party CloudTuya CloudUser grantspermission to thethird-party cloud.1. User logs in or scans a QRcode for login authorization.1.1 User logs in.1.2 User logs in successfully.1.3 Ask the user to confirmauthorization.1.4 User confirms authorization.1.5 User confirms authorization.1.6 Generate a code and redirect the user.Get the accesstoken with the code.2. Get access_token with theclient_id and client_secret code.2.1 Return access_token.Service call.3. Make a service call.3.1 Return the operation result.UserThird Party App/BrowserThird Party CloudTuya CloudGet Access Token with OAuth 2.0 Mode

Applicability

The code mode applies to access to user data.

Get access token

GET:/v1.0/token?grant_type=2&code=cf2xxxxxxxxxxxxxxxxxxxxxxxxxx8fe

If you are using OAuth 2.0 authorization mode on terminal, client_id must be created from App Authorization. This type of client_id is more secure, and can avoid large-scale security issues caused by the leakage of client_id and secret on terminal.

Data sources and API permissions

Data source API permission
User authorization via the webpage User permission package