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

      alipay.system.oauth.token

      Call this interface to get the authorization code. 

      #Request

      #Service address

      Environment

      HTTPS request URL

      Production environment

      Priority: https://globalmapi.alipay.com/gateway.do

      Backup: https://intlmapi.alipay.com/gateway.do

      Test environment

      https://openapi.alipaydev.com/gateway.do

      #Request parameters

      ParameterDescription

      Basic parameter

      app_id

      String(32) Required

      The unique ID that is assigned by Alipay to identify an application.

      Example:2014072300007148

      method

      String(128) Required

      Interface name.

      Example:alipay.system.oauth.token

      format

      String(40)

      JSON and XML are supported.

      Example:JSON

      charset

      String(10) Required

      The charset with which the request data are encoded, such as GBK, UTF-8, and GB2312.

      Example:UTF-8

      sign_type

      String(10) Required

      Sign type. RSA and RSA2 are supported. RSA2 is recommended to be used.

      Example:RSA2

      timestamp

      String(19) Required

      The time when the merchant server sends the request. The format is yyyy-MM-dd HH:mm:ss.

      Example:2014-07-24 03:07:50

      sign 

      String(344) Required

      The signature value. 

      Example:rXaTEfJ7WTDsP1DWRPHARW3uOr19+fzlngMCJBvbhP1XPEa9qZwGGng9oMDloABpJMT2SGeOj46+BUkqCGRO9fH90Vci3hOH01BfYnbhJz3ADK2h7gpjlponx4/sxELN6f2GXi51XKiHKnxMA9XpLLo68q+roY0M/ZFQ1UdnqeM=

      version

      String(3) Required

      The API version. The value is fixed as 1.0.

      Example:1.0

      app_auth_token

      String(40)

      See Overview of the app authorization for details. 

      Business parameter

      grant_type

      String Required

      Indicates the grant type, with a value of authorization_code or refresh_token.

      Example:authorization_code

      code

      String 

      Obtained after the user gives permission. Either code or refresh_token must be used. 

      Example:4b203fe6c11548bcabd8da5bb087a83b

      refresh_token

      String

      This field is used to refresh the access token. Either code or refresh_token must be used.

      Example:201208134b203fe6c11548bcabd8da5bb087a83b


      #Response

      #Response parameters

      ParameterDescription

      Basic parameter

      code

      String Required

      Gateway return code, which indicates whether the request is accepted by Alipay gateway.

      Example:40004

      msg

      String Required

      Description of the gateway return code.

      Example:Business Failed

      sub_code

      String

      Processing result of the request.

      Example:ACQ.TRADE_HAS_SUCCESS

      sub_msg

      String

      Description of the processing result of the request.

      Example:Payment for the transaction is completed.

      sign

      String Required

      The signature value.

      Example:xDffQVBBelDiY/FdJi4/a2iQV1I7TgKDFf/9BUCe6+l1UB55YDOdlCAir8CGlTfa0zLYdX0UaYAa43zY2jLhCTDG+d6EjhCBWsNY74yTdiM95kTNsREgAt4PkOkpsbyZVXdLIShxLFAqI49GIv82J3YtzBcVDDdDeqFcUhfasII=

      Business parameter

      access_token

      String Required

      The token that is used to obtain the user information.

      Example:publicpBa869cad0990e4e17a57ecf7c5469a4b2

      user_id

      String Required

      The unique Alipay user ID

      Example:2088411964574197

      alipay_user_id

      String Required

      Obsolete

      Example:Obsolete

      expires_in

      Number Required

      The validity time of the token. Unit: second.

      Example:300

      re_expires_in

      Number Required

      Used to refresh the validity time of the token. Unit: second.

      Example:300

      refresh_token

      String Required

      Used to refresh the access token.

      Example:publicpB0ff17e364f0743c79b0b0d7f55e20bfc


      #Samples

      #Request

      copy
      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

      copy
      {
          "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="
      }