Docusign 和服务身份验证:无效请求

Docusign and service Authentication : invalid request

我正在尝试使用服务身份验证机制进行登录。但是得到一个无效的 request.I have created the JWT using node jsonwebtoken package.below 是我遇到的错误。

正在复制 JWt 创建逻辑

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'});

你能找到同样的问题吗?

enter image description here

删除 nbf 和名称声明。

将范围声明更改为 "signature impersonation"

https://docs.docusign.com/esign/guide/authentication/oa2_jwt.html#creating-the-jwt-token

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);

});

当使用这个生成的令牌时能够得到 post 正确。 早些时候,令牌打印在控制台上并从那里复制,这导致了问题。 @Larry K 感谢您在范围声明方面的帮助。