I am following this documentation: https://account-d.docusign.com/oauth/token
I am trying the following for the callback API:
router.get('/authGrantReturn', function(req, res){
let query = req.query;
console.log("code: " + req.query.code);
console.log("status: " + req.query.state);
console.log("in authGrantReturn");
return new Promise((resolve, reject)=>{
try{
let bodyData = {
grant_type: 'authorization_code',
code: req.query.code
};
console.log( "========code======")
console.log( req.query.code)
console.log( "========/code======")
let combination = `${integrationKey}:${secretKey}`;
let b64Combination = Buffer.from(combination).toString('base64');
console.log("combination "+ combination)
console.log("b64Combination "+ b64Combination)
fetch('https://account-d.docusign.com/oauth/token',{
method: 'POST',
headers: { 'Authorization': 'Basic ' + b64Combination,
'Content-Type': 'application/x-www-form-urlencoded' },
body: bodyData
})
/* fetch('https://account-d.docusign.com/oauth/token?grant_type:authorization_code&code='+b64Combination,{
method: 'GET',
headers: { 'Authorization': 'Basic ${b64Combination}', 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Encoding': 'gzip'}
}) */
.then(function (res) {
etc....
The above is the callback function called by url that looks like this: https://account-d.docusign.com/oauth/auth?response_type=code&scope=signature&client_id=7c2b8d7e-xxxx-xxxx-xxxx-cda8a50dd73f&state=a39fh23hnf23&redirect_uri=http://example.com/callback/
However I am getting "Bad Request" , the req.query.code is correct, I am not sure about the combination.
What am I missing?