I have a web app in PHP, and JS for front-end. I am connecting to Dcusign through the JWT and exchanging it for an access token, but I keep getting this error:
Decoding JWT did not work
UnexpectedValueException: "kid" invalid, unable to lookup correct key in /html/htdocs/mrt_dghehe/vendor/firebase/php-jwt/src/JWT.php:477
The code for JWT looks like this:
$now = time();
$payload = [
'iss' => $clientId,
'sub' => $apiUserId,
'aud' => 'account-d.docusign',
'scope' => 'signature impersonation',
'iat' => $now,
'exp' => $now + 3600 // 1 hour expiration
];
$privateKey = file_get_contents($privateKeyFilePath);
$jwt = JWT::encode($payload, $privateKey, 'RS256', $keypairID); //kid
$publicKey = file_get_contents('publicKey.key');
try
{
$decodedJWT = JWT::decode($jwt,$publicKey);
print_r($decodedJWT);
echo "This is the decoded JWT";
}
catch(Exception $e)
{
echo "Decoding JWT did not work";
print($e);
Is the kid
the equivalent of the Docusign Keypair ID? I am manually transmitting it when encoding the JWT but I do not even know if it's the right approach.
I have a web app in PHP, and JS for front-end. I am connecting to Dcusign through the JWT and exchanging it for an access token, but I keep getting this error:
Decoding JWT did not work
UnexpectedValueException: "kid" invalid, unable to lookup correct key in /html/htdocs/mrt_dghehe/vendor/firebase/php-jwt/src/JWT.php:477
The code for JWT looks like this:
$now = time();
$payload = [
'iss' => $clientId,
'sub' => $apiUserId,
'aud' => 'account-d.docusign',
'scope' => 'signature impersonation',
'iat' => $now,
'exp' => $now + 3600 // 1 hour expiration
];
$privateKey = file_get_contents($privateKeyFilePath);
$jwt = JWT::encode($payload, $privateKey, 'RS256', $keypairID); //kid
$publicKey = file_get_contents('publicKey.key');
try
{
$decodedJWT = JWT::decode($jwt,$publicKey);
print_r($decodedJWT);
echo "This is the decoded JWT";
}
catch(Exception $e)
{
echo "Decoding JWT did not work";
print($e);
Is the kid
the equivalent of the Docusign Keypair ID? I am manually transmitting it when encoding the JWT but I do not even know if it's the right approach.
1 Answer
Reset to default 1You have to pass an Object of type Key
to the decode-method, not the textual key itself.
$publicKey = new Key(file_get_contents('publicKey.key'), 'RS256');
$decodedJWT = JWT::decode($jwt, $publicKey);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744939403a4602229.html
评论列表(0条)