Refreshing a Token
Typical Scenario
The accessToken obtained by calling the Authentication API has a valid time. When the accessToken is about to expire, an application can call this API to obtain a new accessToken.
API Function
This API is used by an application to obtain a new accessToken from the platform when the existing accessToken is about to expire.
API Description
1 | AuthRefreshOutDTO refreshAuthToken(AuthRefreshInDTO arInDTO) throws NorthApiException
|
Class
Authentication
Parameter Description
AuthRefreshInDTO
| Parameter | Mandatory or Optional | Type | Location | Description |
|---|---|---|---|---|
| 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. |
| refreshToken | Mandatory | String(256) | body | Indicates the refreshToken used for obtaining a new accessToken. The refreshToken is obtained when you call the Authentication or Refreshing a Token API. |
Return Value
AuthRefreshOutDTO
| Parameter | Type | Description |
|---|---|---|
| scope | String(256) | Indicates the applied permission range. This parameter has a fixed value of default. |
| tokenType | String(256) | Indicates the token type. This parameter has a fixed value of bearer. |
| expiresIn | Integer(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. |
| 400 | 50400 | An input parameter is invalid. | An input parameter is invalid. Recommended handling: Check whether parameters carried in the API call request are valid. |
| 401 | 100208 | Incorrect app ID or secret. | Incorrect appId, secret, or refreshToken. 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: Authentication
Next Article: Periodically Refreshing a Token
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.