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 ID 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

String

Validity period of the access token. Unit: second.

scope

String

Authorization scope.

refresh_token

String

Refresh token.

id_token

String

ID 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 ID 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=cU0L3GsEq1vuOJ5iQrRSu5AyPnKL8...&
client_secret=EFj******TcE&
refresh_token=b462******7ef&
grant_type=refresh_token

Example Responses

Status code: 200

Request successful.

{
  "access_token" : "270******6d5",
  "token_type" : "Bearer",
  "expires_in" : 7200,
  "scope" : "openid",
  "refresh_token" : "162******412",
  "id_token" : "eyJ******YTk"
}

Status code: 400

Request error.

{
  "error" : "invalid_grant",
  "error_description" : "Invalid authorization code"
}

Status Codes

Status Code

Description

200

Request successful.

400

Request error.

Error Codes

See Error Codes.