Authentication
Typical Scenario
This API is called by an application for access authentication when the application accesses open APIs of the platform for the first time. After the authentication of the application expires, the application must call this API to perform authentication again so that the application can continue to access open APIs of the platform.
API Function
This API is used by an application to get authenticated before accessing open APIs of the platform.
Note
The Authentication API is the prerequisite for calling other APIs. Except the Authentication API itself, other APIs must use the accessToken obtained by the Authentication API.
If the accessToken is obtained for multiple times, the previous accessToken is invalid and the last accessToken obtained is valid. Do not obtain the accessToken through concurrent attempts.
API Description
1 | def getAuthToken(self, clientInfo)
|
Class
Authentication
Parameter Description
| Parameter | Mandatory or Optional | Type | Location | Description |
|---|---|---|---|---|
| clientInfo | Mandatory | ClientInfo | - | For details, see ClientInfo. |
| Parameter | Mandatory or Optional | Type | Location | Description |
|---|---|---|---|---|
| platformIp | Mandatory | String(256) | path | Indicates the IP address of the platform. |
| platformPort | Mandatory | String(256) | path | Indicates the port of the platform, for example, 8743. |
| appId | Mandatory | String(256) | body | Identifies an application that can be accessed on the platform. The value of this parameter is allocated by the platform when the application is created on the platform. |
| secret | Mandatory | String(256) | body | Indicates a secret used to access the platform. It maps to appId. The value of this parameter is allocated by the platform when the application is created on the platform. |
Return Value
AuthOutDTO structure
| Parameter | Type | Description |
|---|---|---|
| scope | String(256) | Indicates the application permission scope, that is, the scope of platform resources that can be accessed using the accessToken. This parameter has a fixed value of default. |
| tokenType | String(256) | Indicates the type of the accessToken. This parameter has a fixed value of bearer. |
| expiresIn | Number(256) | Indicates the validity time for the platform to generate and return the accessToken, in seconds. |
| accessToken | String(256) | Indicates the authentication parameter that is used to access platform APIs. |
| refreshToken | String(256) | Indicates the authentication parameter that is used to update the accessToken. The validity period of this parameter is 1 month. |
Error Codes
| HTTP Status Code | Error Code | Error Description | Remarks |
|---|---|---|---|
| 400 | 100247 | Operation not allowed. The application has been frozen. | The application is frozen. Recommended handling: Check whether the application is frozen due to arrears. |
| 400 | 102202 | One or more mandatory parameters are null or empty. | Mandatory fields cannot be left blank. Recommended handling: Check whether all the mandatory parameters in the request are set. |
| 401 | 100208 | Incorrect app ID or secret. | appId or secret is incorrect. Recommended handling:
|
| 500 | 50252 | Internal server error. | An internal server error occurs. Recommended handling: An internal error occurs on the IoT platform. Contact IoT platform maintenance personnel. |
Last Article: Secure Application Access
Next Article: Refreshing a Token
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.