我正在尝试使用服务身份验证机制进行登录。但是获取无效请求。我使用节点jsonwebtoken package创建了JWT.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'});
你能找到同样的问题。
答案 0 :(得分:1)
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);
});
使用此生成的令牌时,能够正确发布帖子。 之前,令牌被打印在控制台上,并从那里复制,这就产生了问题。 @Larry K感谢您对范围索赔的帮助。
答案 1 :(得分:0)
删除nbf并命名声明。
将范围声明更改为“签名模仿”
请参阅https://docs.docusign.com/esign/guide/authentication/oa2_jwt.html#creating-the-jwt-token