Get a Token

Last Updated on : 2023-06-28 08:20:06download

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 nameTypeINRequiredDescription
reqTokenReqquerytrueThe API request.

Description of req

Parameter nameTypeINRequiredDescription
grant_typeString trueThe authorization type. Valid values:
  • 1: Simple mode.
  • 2: Authorization code mode.
codeString falseThe authorization code. This parameter is supported only when grant_type is 2.
terminal_idString falseThe terminal ID.
target_uidString falseThe 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 nameTypeDescription
resultTokenResThe response result.

Description of result

Parameter nameTypeDescription
access_tokenStringThe access token.
expire_timeIntegerThe validity period in seconds.
refresh_tokenStringThe refresh token.
uidStringTuya 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.