Apply for Access Token

POST /api/open/v1/alipayhk/merchant/applyToken

Use this interface to request access token with the authorization code retrieved, or refresh access token with refresh token.


Request Headers

Please check API Structure for basics.


Response Headers

Please check API Structure for basics.



Request parameters

grantType string  REQUIRED

A string indicates the purpose of this request.

  • AUTHORIZATION_CODE: Exchange for an access token.
  • REFRESH_TOKEN: Exchange for a new access token when the original one expires.

authCode string  

The authorization code for exchanging access token, given in the redirect url as a query parameter.

REQUIRED when grantType == AUTHORIZATION_CODE

The authCode is only valid for 10 minutes.

refreshToken string  

The refresh token for exchanging a new access token after expiry.

REQUIRED when grantType == REFRESH_TOKEN

Response parameters

result Result  REQUIRED

A metadata object indicates the result of the request.

Show child parameters

accessToken string  

An access token to access user information.

accessTokenExpiryTime string  

Expiry time of the accessToken.

More information:

  • The value follows the ISO 8601 standard format. For example, "2019-11-27T12:01:01+08:00".

customerId string  

The AlipayHK user ID of this authorization process.

refreshToken string  

A refresh token for exchanging a new access token when the original one expires.

refreshTokenExpiryTime string  

Expiry time of the refreshToken.

More information:

  • The value follows the ISO 8601 standard format. For example, "2019-11-27T12:01:01+08:00".
API Explorer

Request

Case
AUTHORIZATION_CODE
Request Body

Response

Response Body

Result/Error codes

CodeValueMessage
SUCCESSSSuccess
AUTH_CODE_EXPIREDFThe authCode has expired, ask user to perform the authorization flow again.
INVALID_AUTHCODEFThe authCode fulfills the generation logic but invalid.
PARAM_ILLEGALFPlease check the parameters of request.
PROCESS_FAILFBusiness process failure, do not retry.
UNKNOWN_EXCEPTIONUAPI failed due to unknown reason, please check with support.
USER_NOT_EXISTFNo user was found with this authCode.
USER_STATUS_ABNORMALFThe status of user with authCode is abnormal.