Alipay, China's leading third-party online payment solutionAlipay, China's leading third-party online payment solution

alipay.intl.oauth.auth.applyToken (Macao)

The API is used by the merchant to get access token from the authSite.

Request

Service address

Environment

URL

Production

https://open.alipaymo.com/api/alipay/intl/oauth/auth/applyToken.htm

Request Header

NameDescription

version
string Required

API version

Example:2.0.0

function

string Required

API interface

Example:alipay.intl.oauth.auth.applyToken

clientId

string(32) Required

Client ID

Example:5C5XSR3USG0CQJ05

reqTime

datetime Required

Request time

Example:2019-12-24T23:18:42-08:00

reqMsgId

string(64) Required

Request message ID

Example:8887ef5096774cb9a8aa8a4e07acf714

Request Body

NameDescription
grantType Required

Grant type. The accessToken could be granted by authCode or refreshToken.

Example:AUTHORIZATION_CODE

authMerchantId

string(64) Required

Auth merchant ID. The auth merchant can be authorized by the user  to access user resources.

Example:218820000000023

authSite Required

The site which can authorize the user.

Example:ALIPAY_MO

authCode

string(64) Required

An authorization code which the caller can used to obtain an access token.

Example:4b203fe6c11548bcabd8da5bb087a83b

Synchronous Response

Response Header

NameDescription

version
string Required

API version

Example:2.0.0

function

string Required

API interface

Example:alipay.intl.oauth.auth.applyToken

clientId

string(32) Required

Client ID

Example:5C5XSR3USG0CQJ05

reqTime

datetime Required

Request time

Example:2019-12-24T23:18:42-08:00

reqMsgId

string(64) Required

Request message ID

Example:8887ef5096774cb9a8aa8a4e07acf714

Response body

NameDescription

resultInfo

<resultInfoRequired

Result info
Example:

{  

"resultStatus": "S",  

"resultCodeId": "00000000",  

"resultCode":"SUCCESS",  

"resultMsg": "result message"  

}

accessTokenInfo

<accessTokenInfo>Required

The detailed accessToken information.

Example:

{    

"accessToken": "publicpBa869cad0990e4e17a57ecf7c5469a4b2",    

"expiresIn": "2001-07-04T12:08:56+05:30",    

"refreshToken":"201510BB0c409dd5758b4d939d4008a525463X62",    

"reExpiresIn": "2001-07-04T12:08:56+05:30", 

"tokenStatus":"ACTIVE"  

}

authSiteUserId

string(64) Required

The parameter identifies the unique user id within the authSite. Recommend to provide.

Example: 2182123456123456

Request Sample

copy
{
    "request":{
        "head": {
          "version": "2.0.0",
          "function": "alipay.intl.oauth.auth.applyToken",
          "clientId": "5C5XSR3USG0CQJ05",
          "reqTime": "2020-08-11T18:38:52+08:00",
          "reqMsgId": "e0a15879bad24193b3452f1b4110620f"
        },
        "body": {
          "authCode": "0iU9JGnemDnVHE2OPYwxBqo2zCccz349",
          "authMerchantId": "2182400000001037",
          "authSite": "ALIPAY_MO",
          "grantType": "AUTHORIZATION_CODE"
        }
    },
    "signature":"signature string"
}

Response Sample

copy
{
    "response":{
        "body": {
          "accessTokenInfo": {
            "accessToken": "xoC00000DEq2TbeMG3yHKL11111AL7Z7vHjPhu6A6O000349",
            "expiresIn": "2021-08-11T03:38:52-07:00",
            "reExpiresIn": "2037-12-31T16:00:20-08:00",
            "refreshToken": "bxj2LImd44444K9VoLtVEY33333skHdL4sfrmyyCRG001349",
            "tokenStatus": "ACTIVE"
          },
          "authSiteUserId": "2182123456123456",
          "resultInfo": {
            "resultCode": "SUCCESS",
            "resultCodeId": "00000000",
            "resultMsg": "execute success",
            "resultStatus": "S"
          }
        },
        "head": {
          "clientId": "5C5XSR3USG0CQJ05",
          "function": "alipay.intl.oauth.auth.applyToken",
          "reqMsgId": "e0a15879bad24193b3452f1b4110620f",
          "respTime": "2020-08-11T03:38:52-07:00",
          "version": "2.0.0"
        }
    },
    "signature":"signature string"
}

Result Code

No.ResultCodeIdResultCodeResultStatusRemarks
100000011RISK_REJECTFRisk reject
212002005USER_NOT_EXISTFUser does not exist
312002006

USER_STATUS_ABNORMAL

FUser status is not normal.
412002027OTP_VERIFY_TIMES_EXCEED_LIMITFVerify code failed too many times, user must get a new code.
512002026OTP_VERIFY_UNMATCHEDFVerify code invalid
612014174AUTH_CODE_INVALIDFauthCode is invalid
712014175REFRESH_TOKEN_INVALIDFRefresh token is invalid
No.ResultCodeIdResultCodeResultStatusRemarks
100000000SUCCESSSSuccess
200000019PROCESS_FAILFGeneral business failure. No retry.
300000901UNKNOWN_EXCEPTIONUAPI failed due to unknown reason.
400000004PARAM_ILLEGALFIllegal parameters. For example, non-numeric input, invalid date.
500000007INVALID_SIGNATUREFSignature is invalid.
600000008KEY_NO_FOUNDFKey is not found.
700000013NO_INTERFACE_DEFFAPI is not defined
800000014API_IS_INVALIDFAPI is invalid (or not active)
900000016OAUTH_FAILEDFoAuth authentication failed
1000000021ACCESS_DENIEDFAccess denied
1112014152CLIENT_FORBIDDEN_ACCESS_APIFClient is not authorized to use this API
1212014155UNKNOWN_CLIENTFUnknown client
1312014156INVALID_CLIENT_STATUSFInvalid client status
1400000024REQUEST_TRAFFIC_EXCEED_LIMITFRequest traffic exceed limit.