Get Token

Last Updated on : 2025-03-06 06:13:01download

This topic describes the API operations that are used to get a token.

API description

In cloud-to-cloud integration scenarios, you can request cloud API authorizations from the platform in simple mode and implicitly get a token.

Prerequisites

Please read these documents carefully before making API requests.

API address

GET: /v1.0/token

Request parameters

Parameter Type Parameter location Required Description
req TokenReq query true The API request.

Description of req

Parameter Type Parameter location Required Description
grant_type String query true The authorization type. Valid values:
  • 1: simple mode.
  • 2: OAuth 2.0 mode.
code String query false The authorization code. It is available only when the value of grant_type is 2.
terminal_id String query false The terminal ID.
target_uid String query false The unique identifier of a user authenticated by Identity and Access Management (IAM). The IAM integration is supported only when the value of grant_type is 1.

Response parameters

Parameter Type Description
result TokenRes The response result.

Description of result

Parameter Type Description
access_token String The access token.
expire_time Integer The validity period in seconds.
refresh_token String The refresh token.
uid String Tuya user ID.

Sample request

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

Sample response

{
    "expire_time": 7200,
    "access_token": "**",
    "uid": "eu*****",
    "refresh_token": "**"
}

Error code

For more information, see Global Error Codes.