Reputation: 331
I am trying to use service authentication mechanism for logging in. But getting an invalid request.I have created the JWT using node jsonwebtoken package.below is the error I am getting.
Copying the JWt creation logic
var jwt = require('jsonwebtoken');
var fs = require('fs');
//creating the payload for docusign
var payload = {
"iss": "cb91877d-1d55-48ae-88d7-fd215c4fe2ca",
"sub": "6cd4ea4e-3e68-4994-88b1-a321847cbf7e",
"iat": 1508868716,
"exp": 1508869916,
"aud": "account-d.docusign.com",
"scope": "signature",
"nbf":1508868716,
"name": "neeush"
}
var cert = fs.readFileSync('private.pem'); // get private key
var token = jwt.sign(payload, cert, { algorithm: 'RS256'});
Can you find any issues in the same.
Upvotes: 0
Views: 515
Reputation: 331
var jwt = require('jsonwebtoken');
var fs = require('fs');
//creating the payload for docusign
var payload = {
"iss": "cb91877d-1d55-48ae-88d7-fd215c4fe2ca",
"sub": "6cd4ea4e-3e68-4994-88b1-a321847cbf7e",
"iat": 1509096042,
"exp": 1509099042,
"aud": "account-d.docusign.com",
"scope": "signature impersonation",
"name" :"name value" //not required
}
var cert = fs.readFileSync('private.pem'); // get private key
var token = jwt.sign(payload, cert, { algorithm: 'RS256'});
console.log(token)
console.log('---------------------------------------------------');
//printing the token to a file
fs.writeFile('jwttoken.txt', token, function (err) {
if (err)
return console.log(err);
});
When the this generated token is used able to get post correct. Earlier the token was printed on th console and copied from there which was creating the problem. @Larry K Thanks for the help with the scope claim.
Upvotes: 1
Reputation: 49104
Remove nbf and name claims.
Change scope claim to "signature impersonation"
See https://docs.docusign.com/esign/guide/authentication/oa2_jwt.html#creating-the-jwt-token
Upvotes: 0