Apply for Access Token
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.
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.
when
grantType
== REFRESH_TOKEN
Response parameters
result Result REQUIRED
A metadata object indicates the result of the request.
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".
Request
Response
Result/Error codes
Code | Value | Message |
---|---|---|
SUCCESS | S | Success |
AUTH_CODE_EXPIRED | F | The authCode has expired, ask user to perform the authorization flow again. |
INVALID_AUTHCODE | F | The authCode fulfills the generation logic but invalid. |
PARAM_ILLEGAL | F | Please check the parameters of request. |
PROCESS_FAIL | F | Business process failure, do not retry. |
UNKNOWN_EXCEPTION | U | API failed due to unknown reason, please check with support. |
USER_NOT_EXIST | F | No user was found with this authCode. |
USER_STATUS_ABNORMAL | F | The status of user with authCode is abnormal. |