简体   繁体   中英

Docusign and service Authentication : invalid request

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.

enter image description here

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM