Skip to main content
Question

I am trying to connect to Docusign through my WebApp and my JWT is failing


Forum|alt.badge.img+1

I have a web app in PHP and JS for front. 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 workUnexpectedValueException: "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:

   $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. Please help!

0 replies

Be the first to reply!