alipay.system.oauth.token
Call this interface to get the authorization code.
Request
Service address
Environment | HTTPS request URL |
Production environment | |
Test environment |
Request parameters
Parameter | Description |
Basic parameter | |
app_id String(32) | The unique ID that is assigned by Alipay to identify an application.
|
method String(128) | Interface name.
|
format String(40) | JSON and XML are supported.
|
charset String(10) | The charset with which the request data are encoded, such as GBK, UTF-8, and GB2312.
|
sign_type String(10) | Sign type. RSA and RSA2 are supported. RSA2 is recommended to be used.
|
timestamp String(19) | The time when the merchant server sends the request. The format is yyyy-MM-dd HH:mm:ss.
|
sign String(344) | The signature value.
|
version String(3) | The API version. The value is fixed as 1.0.
|
app_auth_token String(40) | See Overview of the app authorization for details. |
Business parameter | |
grant_type String | Indicates the grant type, with a value of authorization_code or refresh_token.
|
code String | Obtained after the user gives permission. Either code or refresh_token must be used.
|
refresh_token String | This field is used to refresh the access token. Either code or refresh_token must be used.
|
Response
Response parameters
Parameter | Description |
Basic parameter | |
code String | Gateway return code, which indicates whether the request is accepted by Alipay gateway.
|
msg String | Description of the gateway return code.
|
sub_code String | Processing result of the request.
|
sub_msg String | Description of the processing result of the request.
|
sign String | The signature value.
|
Business parameter | |
access_token String | The token that is used to obtain the user information.
|
user_id String | The unique Alipay user ID
|
alipay_user_id String | Obsolete
|
expires_in Number | The validity time of the token. Unit: second.
|
re_expires_in Number | Used to refresh the validity time of the token. Unit: second.
|
refresh_token String | Used to refresh the access token.
|
Samples
Request
REQUEST URL: https://globalopenapi.alipay.com/gateway.do
REQUEST METHOD: POST
CONTENT:
app_id=2014070100171525
method=alipay.system.oauth.token
charset=GBK
sign_type=RSA2
timestamp=2014-01-01 08:08:08
sign=rXaTEfJ7WTDsP1DWRPHARW3uOr19+fzlngMCJBvbhP1XPEa9qZwGGng9oMDloABpJMT2SGeOj46+BUkqCGRO9fH90Vci3hOH01BfYnbhJz3ADK2h7gpjlponx4/sxELN6f2GXi51XKiHKnxMA9XpLLo68q+roY0M/ZFQ1UdnqeM=
version=1.0
grant_type=authorization_code
code=4b203fe6c11548bcabd8da5bb087a83b
refresh_token=201208134b203fe6c11548bcabd8da5bb087a83b
Response
{
"alipay_system_oauth_token_response": {
"code": "10000",
"msg": "Success",
"access_token": "publicpBa869cad0990e4e17a57ecf7c5469a4b2",
"user_id": "2088411964574197",
"alipay_user_id": "20881007434917916336963360919773",
"expires_in": 300,
"re_expires_in": 300,
"refresh_token": "publicpB0ff17e364f0743c79b0b0d7f55e20bfc"
},
"sign": "xDffQVBBelDiY/FdJi4/a2iQV1I7TgKDFf/9BUCe6+l1UB55YDOdlCAir8CGlTfa0zLYdX0UaYAa43zY2jLhCTDG+d6EjhCBWsNY74yTdiM95kTNsREgAt4PkOkpsbyZVXdLIShxLFAqI49GIv82J3YtzBcVDDdDeqFcUhfasII="
}