Authentication
Developer Guide
fs_id
used as a unique identifier to your account, while client_id
and client_secret
used to acquire an access token. An access token grants limited access to a fulfillment service's account. The client_secret
should be treated as a password and stored securely. There are two ways to generate the access token, using HTTP request or using Postman.
Using HTTP Request to Obtain Access Token
You need to encode your client_id
and client_secret
to base64 and make a POST request to https://accounts.tokopedia.com/token
. Here are the complete steps:
- Visit base64encode.org
- Insert your Client ID and Client Secret with the following format:
client_id:client_secret
- Encode to a base64 string. The encoded string will be like this:
Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQK
- Make a POST request to
https://accounts.tokopedia.com/token
and use the encoded string as the Basic Authorization Token. Example request:
curl -X POST \
'https://accounts.tokopedia.com/token?grant_type=client_credentials' \
-H 'Authorization: Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQK' \
-H 'Content-Length: 0' \
-H 'User-Agent: PostmanRuntime/7.17.1'
- If successful, you will receive an
access_token
response. When an access token expires, you should request a new token. Example response:
{
"access_token": "LSPr7x7sRGaewzwZE6IcuA",
"expires_in": 2592000,
"token_type": "Bearer"
}
- You can use the
access_token
to make HTTP request, for example:
curl -X GET \
'https://fs.tokopedia.net/v1/sample/endpoint' \
-H 'Authorization: Bearer LSPr7x7sRGaewzwZE6IcuA'
Using Postman
Postman is an application that lets you send HTTP requests to Tokopedia API endpoints. You can use Postman to obtain access_token
without doing base64 encoding manually. Here are the complete steps:
- Open Postman. Visit Get Postman to download.
- Click the Authorization tab under the request URL and select OAuth 2.0 as the Type
- Click on the Get New Access Token
- Select Client Credentials as the Grant Type
- Input
https://accounts.tokopedia.com/token
to the Access Token URL field - Enter your Client ID and Client Secret
- Finally, click on the Request Token button.