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_dgheorghe/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.com',
'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.