Get a Token

Last Updated on : 2024-09-10 08:48:30

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

Prerequisites

Please read these documents carefully before making API requests.
Quick Start

API Sample Request

API address

GET: /v1.0/token

Request parameter

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

Description of req

Parameter name Type IN Required Description
grant_type String true The authorization type. Valid values:
  • 1: Simple mode.
  • 2: OAuth 2.0 mode.
code String false The authorization code. This parameter is supported only when grant_type is 2.
terminal_id String false The terminal ID.
target_uid String false The unique identifier of a user authenticated by Identity and Access Management (IAM). The IAM integration is supported only when grant_type is 1.

Return parameter

Parameter name Type Description
result TokenRes The response result.

Description of result

Parameter name 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.

Request example

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

Return example

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

Error code

For more information, see error code.