Antom, leading provider of tailored payment solutions

alipay.intl.oauth.auth.applyToken

You can use this interface to get access token from the authSite. In redirect signup flow, this interface is used together with the alipay.intl.oauth.auth.prepareForRedirect API and the authSite returns the authCode for you. The correct authCode can be used for invoking the alipay.intl.oauth.auth.applyToken API and make you get the access token.

The authcode is valid for only 10 minutes, therefore, you need to use this authcode to apply for the access token within 10 minutes. AlipayHK returns the accessToken as the response if the request passes the verifification.

Request Parameters

No
Name
Description
Type
Length
Required
Remarks
Sample
1
version
API version
string
8
Y
As per the respective API reference
2.0.0
2
function
API interface
string
128
Y
According to specifications defined by each business domain
alipay.intl.function
3
clientId
Client ID
string
32
Y
Provided by AlipayHK, used to identify partner and application system
4Q5XSH6SSG02T006
4
reqTime
Request time
datetime
/
Y
DateTime with timezone, which follows the ISO-8601 standard.
Refer to: RFC 3339 Section 5.6
2001-07-04T12:08:56+05:30
5
reqMsgId
Request message ID
string
64
Y
Each request will be assigned with a unique id (uuid).
The reqMsgId identify an unique system request, it is not used to identity an unique business request.
9cfa41d13571c335d66ce162ef565574e7e8f9ef57971451eca62896ac88e264
6
reserve
Reserved for future implementation
string
256
N
Key/Value
{}

Body

No
Name
Description
Type
Length
Required
Remarks
Sample
1
grantType
Grant type. The accessToken could be granted by authCode or refreshToken.
64
Y
AUTHORIZATION_CODE
2
authMerchantId
Auth merchant ID. The auth merchant can be authorized by the user  to access user resources.
string
64
Y
2160400000002012
3
authSite
The site which can authorize the user.
enum<SiteEnum>
64
Y
ALIPAY_HK
4
authCode
An authorization code which the caller can used to obtain an access token.
Note:
This parameter is requiredwhen grantType = AUTHORIZATION_CODE
string
64
N
Authentication code. The authCode is generated by the authSite and returned to the merchant.
Y4hLMxQkEs4QvAx9l8s03qIcif12y969

Request Sample

{
    "request": {
        "head": {
            "version": "2.0.0",
            "function": "alipay.intl.oauth.auth.applyToken",
            "clientId": "4Q5XPV504B0A5302",
            "reqTime": "2018-12-11T13:16:46+08:00",
            "reqMsgId": "9cfa41d13571c335d66ce162ef565574e7e8f9ef57971451eca62896ac88e264",
            "reserve": "{}"
        },
        "body": {
            "grantType": "AUTHORIZATION_CODE",
            "authMerchantId": "2160400000002012",
            "authSite": "ALIPAY_HK",
            "authCode": "Y4hLMxQkEs4QvAx9l8s03qIcif12y969"
        }
    },
    "signature": "XXX"
}

Response parameter

Header

No
Name
Description
Type
Length
Required
Remarks
Sample
1
version
API version
string
8
Y
As per the respective API reference
2.0.0
2
function
API interface
string
128
Y
According to specifications defined by each business domain
alipay.intl.function
3
clientId
Client ID
string
32
Y
Provided by AlipayHK, used to identify partner and application system
4Q5XSH6SSG02T006
4
respTime
Response time
datetime
/
Y
DateTime with timezone, which follows the ISO-8601 standard.  
Refer to: RFC 3339 Section 5.6
2001-07-04T12:08:56+05:30
5
reqMsgId
Request message ID
string
64
Y
Each request will be assigned with a unique id (uuid).
9cfa41d13571c335d66ce162ef565574e7e8f9ef57971451eca62896ac88e264
6
reserve
Reserved for future implementation
string
256
N
Key/Value
{}

Body

No
Name
Description
Type
Length
Required
Remarks
Sample
1
resultInfo
Result info
/
Y
"resultInfo": {
"resultCode": "SUCCESS",
"resultCodeId": "00000000",
"resultMsg": "execute success",
"resultStatus": "S"
}
2
accessTokenInfo
The detailed accessToken information.
Note:
This parameter is required when resultInfo.resultCode = SUCCESS
/
N
"accessTokenInfo": {
"accessToken": "nnQ9B9GGoOB0ytpLdvlOqr7pLEWrnptVpmQXPRwj77000969",
"expiresIn": "2038-01-01T00:00:36-08:00",
"reExpiresIn": "2038-01-01T00:00:36-08:00",
"refreshToken": "dIQfFcubLFSuY3ueZqsyI6VPrqB57Xx9nBNiPj9B07001969",
"tokenStatus": "ACTIVE"
}

Response Sample

{         
   "response": {
       "body": {
           "accessTokenInfo": {
                "accessToken": "nnQ9B9GGoOB0ytpLdvlOqr7pLEWrnptVpmQXPRwj77000969",
                "expiresIn": "2038-01-01T00:00:36-08:00",
                "reExpiresIn": "2038-01-01T00:00:36-08:00",
                "refreshToken": "dIQfFcubLFSuY3ueZqsyI6VPrqB57Xx9nBNiPj9B07001969",
                "tokenStatus": "ACTIVE"
           },
           "authSiteUserId": "2160205083989964",
            "resultInfo": {
                "resultCode": "SUCCESS",
                "resultCodeId": "00000000",
                "resultMsg": "execute success",
                "resultStatus": "S"
           }
       },
       "head": {
           "clientId": "4Q5XPV504B0A5302",
           "function": "alipay.intl.oauth.auth.applyToken",
           "reqMsgId": "9cfa41d13571c335d66ce162ef565574e7e8f9ef57971451eca62896ac88e264",
           "reserve": "{}",
           "respTime": "2018-12-10T21:16:47-08:00",
           "version": "2.0.0"
       }
   },
"signature": "xxx"
}

Business Error code

Functional Logic Result Code

No
ResultCodeId
ResultCode
ResultStatus
Remarks
1
00000019
PROCESS_FAIL
F
General business failure
2
12005123
AUTH_NOT_SUCCESS
F
The authorization is not success
3
12007001RISK_AML_REJECT
F
Anti money laundering risk reject
4
12007615
PRODUCT_CODE_INVALID
F
Product code invalid
5
00000004
PARAM_ILLEGAL
F
Illegal parameters
6
12002006
USER_STATUS_ABNORMAL
F
User status is not normal
7
00000901
UNKNOWN_EXCEPTION
U
Unknown exception
8
00000011
RISK_REJECT
F
Risk reject
9
12002005
USER_NOT_EXIST
F
User does not exist
10
12002006
USER_STATUS_ABNORMAL
F
User status is not normal
11
12002027
OTP_VERIFY_TIMES_EXCEED_LIMIT
F
Verify code failed too many times, user must get a new code.
12
12002026
OTP_VERIFY_UNMATCHED
F
Verify code invalid
13
12014174
AUTH_CODE_INVALID
F
authCode is invalid
14
12014155
UNKNOWN_CLIENT
F
Unknown client