Token B2B
access token yang berfungsi sebagai autentikasi saat ingin mengakses API yang lain.
Service Info
HTTP Method | POST |
---|---|
Service Code | 73 |
Http Method | POST |
Path | .../access-token/b2b |
Header
Header Name | Tipe Data | Wajib | Deskripsi |
---|---|---|---|
Content-Type | String | Y | application/json |
X-TIMESTAMP | String | Y | Waktu lokal klien saat ini yyyy-MM-ddTHH:mm:ss.SSSTZD format |
X-CLIENT-KEY | String | Y | Client’s client_id (diberikan pada saat onboarding ) |
X-SIGNATURE | String | Y | Dibuat dengan algoritma asymmetric without token : Signature Generation |
Body
Parameter | Tipe Data | Wajib | Deskripsi |
---|---|---|---|
grantType | String | Y | Nomor transaksi merchant Length: <= 18 characters Allowed Value: client_credentials |
- JSON
- CURL
- PHP
- NODE JS
- GO
{
"grantType": "client_credentials"
}
curl --location --request POST '../access-token/b2b' \
--header 'x-timestamp: 2024-01-16T10:54:21+07:00' \
--header 'x-client-key: 6c57db4e-9e11-4951-9bcf-d6f177dafbcc' \
--header 'x-signature: "htDUhG15DEdz3WCbkDZUdc8sodfb0cdx6W15bGoaadbhe5FOh30pMyiLqPrK46w6i9cm10WXxUXI/2x6+tp5OPXAgAGWahx9Fd9QsWfuxfbDJMBi9UPYzgJN2keF7K+p6KesXbR/QjaNDA6K7I+RcYXDNHC6lq0EZqDPoR/A6+uaJhR+WBNDSTnlqQb6OS1TRSdRSS/pcpIPuv+5nWgObQM6i7FLYaJERZ3b+tWAgvhddWKq+d7/oh/by/QgKqeciJCsm/3D7UJAvxc/duSILzkv2D0wB+8WB4UF8/qChLbekbC5dqJMZX/DrKcM5l6rxwRK+RUZJrV8lToCQVLDEA==' \
--header 'x-patner-id: 6c57db4e-9e11-4951-9bcf-d6f177dafbcc' \
--header 'x-external-id: 2024-05-15T04:03:01.317Z' \
--header 'channel-id: 23412' \
--header 'content-type: application/json' \
--data-raw '{
"grantType": "client_credentials"
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '../access-token/b2b',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"grantType": "client_credentials"
}',
CURLOPT_HTTPHEADER => array(
'x-timestamp: 2024-01-16T10:54:21+07:00',
'x-client-key: 6c57db4e-9e11-4951-9bcf-d6f177dafbcc',
'x-signature: "htDUhG15DEdz3WCbkDZUdc8sodfb0cdx6W15bGoaadbhe5FOh30pMyiLqPrK46w6i9cm10WXxUXI/2x6+tp5OPXAgAGWahx9Fd9QsWfuxfbDJMBi9UPYzgJN2keF7K+p6KesXbR/QjaNDA6K7I+RcYXDNHC6lq0EZqDPoR/A6+uaJhR+WBNDSTnlqQb6OS1TRSdRSS/pcpIPuv+5nWgObQM6i7FLYaJERZ3b+tWAgvhddWKq+d7/oh/by/QgKqeciJCsm/3D7UJAvxc/duSILzkv2D0wB+8WB4UF8/qChLbekbC5dqJMZX/DrKcM5l6rxwRK+RUZJrV8lToCQVLDEA==',
'x-patner-id: 6c57db4e-9e11-4951-9bcf-d6f177dafbcc',
'x-external-id: 2024-05-15T04:04:07.676Z',
'channel-id: 23412',
'content-type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': '../access-token/b2b',
'headers': {
'x-timestamp': ' 2024-01-16T10:54:21+07:00',
'x-client-key': '6c57db4e-9e11-4951-9bcf-d6f177dafbcc',
'x-signature': '"htDUhG15DEdz3WCbkDZUdc8sodfb0cdx6W15bGoaadbhe5FOh30pMyiLqPrK46w6i9cm10WXxUXI/2x6+tp5OPXAgAGWahx9Fd9QsWfuxfbDJMBi9UPYzgJN2keF7K+p6KesXbR/QjaNDA6K7I+RcYXDNHC6lq0EZqDPoR/A6+uaJhR+WBNDSTnlqQb6OS1TRSdRSS/pcpIPuv+5nWgObQM6i7FLYaJERZ3b+tWAgvhddWKq+d7/oh/by/QgKqeciJCsm/3D7UJAvxc/duSILzkv2D0wB+8WB4UF8/qChLbekbC5dqJMZX/DrKcM5l6rxwRK+RUZJrV8lToCQVLDEA==',
'x-patner-id': '6c57db4e-9e11-4951-9bcf-d6f177dafbcc',
'x-external-id': '2024-05-15T04:04:53.208Z',
'channel-id': ' 23412',
'content-type': ' application/json'
},
body: '{\n "grantType": "client_credentials"\n}'
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "../access-token/b2b"
method := "POST"
payload := strings.NewReader(`{
"grantType": "client_credentials"
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("x-timestamp", " 2024-01-16T10:54:21+07:00")
req.Header.Add("x-client-key", "6c57db4e-9e11-4951-9bcf-d6f177dafbcc")
req.Header.Add("x-signature", "\"htDUhG15DEdz3WCbkDZUdc8sodfb0cdx6W15bGoaadbhe5FOh30pMyiLqPrK46w6i9cm10WXxUXI/2x6+tp5OPXAgAGWahx9Fd9QsWfuxfbDJMBi9UPYzgJN2keF7K+p6KesXbR/QjaNDA6K7I+RcYXDNHC6lq0EZqDPoR/A6+uaJhR+WBNDSTnlqQb6OS1TRSdRSS/pcpIPuv+5nWgObQM6i7FLYaJERZ3b+tWAgvhddWKq+d7/oh/by/QgKqeciJCsm/3D7UJAvxc/duSILzkv2D0wB+8WB4UF8/qChLbekbC5dqJMZX/DrKcM5l6rxwRK+RUZJrV8lToCQVLDEA==")
req.Header.Add("x-patner-id", "6c57db4e-9e11-4951-9bcf-d6f177dafbcc")
req.Header.Add("x-external-id", "2024-05-15T04:05:11.618Z")
req.Header.Add("channel-id", " 23412")
req.Header.Add("content-type", " application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Response Structure
Parameter | Tipe Data | Deskripsi |
---|---|---|
responseCode | String | Kode response |
responseMessage | String | Pesan response |
accessToken | String | Kode Rahasia yang akan digunakan pada setiap request |
tokenType | String | Jenis Type Kode token Dengan Value Bearer |
expiresIn | String | Sesi Token berakhir dalam hitungan detik : 900 (15 menit) |
{
"responseCode": "2007300,",
"responseMessage": "Successful,",
"accessToken": "2758e0d0-1646-4452-ad24-2d99406b393a",
"tokenType": "Bearer",
"expiresIn": 900
}
List Response Code Access Token - B2B
Response Code | Response Message | Description |
---|---|---|
2007300 | Success | |
4007301 | Invalid field format { field name } | |
4007302 | Invalid mandatory field {field name} | |
4017300 | Unauthorized. Invalid Signature | X-Signature salah |
4097300 | Cannot use same X-EXTERNAL-ID in same day | X-External-ID sudah pernah digunakan di hari yang sama |
4047301 | Bad Request | Request header ada yang salah / kurang |
4047301 | Unauthorized. Client Forbidden Access API | Partner tidak dapat mengakses api terkait |