Last updated 2 years ago
client_id
client_secret
Authorization
Basic base64(client_id:client_secret)
base64(client_id:client_secret)
yes
Code
const crypto = require('crypto'); const axios = require("axios").default; //generate access token const client_id ='96951f24-f6c4-4583-89c0-87fa6489d04a'; const client_secret ='54ed876c-c7d2-4b84-b615-35c26e0d5fce'; var Sign =Buffer.from(`${client_id}:${client_secret}`).toString('base64'); console.log(Sign); try { const result = await axios.post(`sandbox.bca.co.id/api/oauth/token`,new URLSearchParams({ grant_type: 'client_credentials' }),{ headers: { 'Authorization': `Basic ${Sign}`, 'Content-Type': 'application/x-www-form-urlencoded', }, }); return res.status(201).send(result.data); } catch (err) { return res.status(400).send(err.response.data); ; }