Access Token
Access Token API is an API call that can be used to acquire B2B access token. This access token will be used to access subsequent Transactional API such as payment, refund, query, etc.
Merchant server collects access token by calling ShopeePay system.
ShopeePay will generate the access token and return the token to Merchant.
Access token has validity period, once it passes the validity period client need to collect a new access token.
Merchant can access Transactional API by sending access token on API header.
Specification
The following table is a specification of this API:
HTTP Method | POST |
---|---|
Service Code | 73 |
Path | .../v1.0/access-token/b2b |
Version | v1.0 |
Request Parameters
Field | Type | Mandatory | Description |
---|---|---|---|
grantType | String | M | Grant Type Value: “client_credentials” |
Sample API Request
REQUEST
{"grantType":"client_credentials"}
Copy
Response Parameters
Field | Type | Mandatory | Description |
---|---|---|---|
responseCode | String | M | Error code to specify the error returned. |
responseMessage | String | M | Debug message to provide more information. |
accessToken | String | M | A string representing an authorization issued to the client that used to access protected resources. |
tokenType | String | M | Token Type Value: “Bearer” |
expiresIn | String | M | Session expiry in seconds.
|
Sample API Response
RESPONSE
{"responseCode": "2007300","responseMessage": "Successful","accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJDbGllbnRJRCI6Ik1IMjAyMjA3MDhCIiwiZXhwIjoxNjU4NzIwOTk5NjY5LCJpYXQiOjE2NTg3MTczOTk2NjksImlzcyI6Ik1IMjAyMjA3MDhCIiwibmJmIjoxNjU4NzE3Mzk5NjY5fQ.hv0dubKQTeTR4n2VK_qzf8N3MPUv1wEc8LiMa1eglVc","tokenType": "Bearer","expiresIn": "900"}
Copy
Response Codes
HTTP Code | Service Code | Sub-Error Code | Response Code | Response Message | Partner Action |
---|---|---|---|---|---|
200 | 73 | 00 | 2007300 | Successful | Proceed to invoke the next API. The value of “ accessToken” is inserted into HTTP-Header “ Authorization” |
400 | 73 | 00 | 4007300 | Bad Request | Retry or contact ShopeePay for support |
400 | 73 | 01 | 4007301 | Invalid Field Format | Retry or contact ShopeePay for support |
400 | 73 | 02 | 4007302 | Invalid Mandatory Field + {error message} | Retry or contact ShopeePay for support |
401 | 73 | 00 | 4017300 | Unauthorized.{error message} | Retry or contact ShopeePay for support |
401 | 73 | 01 | 4017301 | Invalid Token | Retry or contact ShopeePay for support |
409 | 73 | 00 | 4097300 | Conflict | Retry or contact ShopeePay for support |
500 | 73 | 01 | 5007301 | Internal Server Error | Retry or contact ShopeePay for support |
504 | 73 | 00 | 5047300 | Timeout | Retry or contact ShopeePay for support |