Updated on 2024-12-30 GMT+08:00

Refreshing an Access Token

Function

This API is used to refresh an access token.

URI

POST /api/v1/oauth2/token

Request Parameters

Table 1 FormData parameters

Parameter

Mandatory

Type

Description

client_id

Yes

String

Application ID, which is a client ID allocated to an application after registration.

client_secret

Yes

String

Application secret, which is a client secret allocated to an application after registration.

refresh_token

Yes

String

Refresh token, which is returned when the API for obtaining an access token is called.

grant_type

Yes

String

Grant type. The value is fixed at refresh_token.

Response Parameters

Status code: 200

Table 2 Response body parameters

Parameter

Type

Description

access_token

String

Access token that the authorization server returns to the third-party application.

token_type

String

Type of the access token. Fixed value: Bearer.

expires_in

Long

Validity period of the access token. Unit: second.

scope

String

Authorization scope.

refresh_token

String

Refresh token.

Status code: 400

Table 3 Response body parameters

Parameter

Type

Description

error

String

Error type.

error_description

String

Error description.

Example Requests

Refresh access_token based on refresh_token. refresh_token can be obtained by calling the API for obtaining an access token. client_id and client_secret use ClientId and ClientSecret assigned during the application registration. The value of grant_type is fixed at refresh_token.

POST https://{domain_name}/api/v1/oauth2/token

Content-Type: application/x-www-form-urlencoded

client_id=NzZeWuiJa91dPSRdZQChMazIh13AW...&
client_secret=NzZ******3AW&
refresh_token=e8e******7e3&
grant_type=refresh_token

Example Responses

Status code: 200

Request successful.

{
  "access_token" : "9b0******df2",
  "token_type" : "Bearer",
  "expires_in" : 7200,
  "scope" : "get_user_info",
  "refresh_token" : "dec******7f1"
}

Status code: 400

Request error.

{
  "error" : "invalid_grant",
  "error_description" : "Invalid refresh token"
}

Status Codes

Status Code

Description

200

Request successful.

400

Request error.

Error Codes

See Error Codes.