Authentication Method

Last Updated on : 2024-04-26 09:27:48download

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 access token.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
  • Required parameters: client_id (the request header), secret (used to sign the request), and grant_type (fixed to 1).
  • References: View Project Details for the client_id and secret, Sign Requests for the signing algorithms, and Get a Token for the API reference.

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

Code mode

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 access tokenwith 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 Code Mode

Applicability

The code mode applies to access to user data.

Get access token

GET:/v1.0/token?grant_type=2&code=cf2xxxxxxxxxxxxxxxxxxxxxxxxxx8fe
  • Required parameters: client_id (the request header), secret (used to sign the request), code (user authorization code), and grant_type (fixed to 2).
  • References: View Project Details for the client_id and secret, Sign Requests for the signing algorithms, and Get a Token for the API reference.

Data sources and API permissions

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