/**
  * Creates a signed JWT.
  * @param array $payload
  * @return string The signed JWT.
  */
 private function makeSignedJwt($payload)
 {
     $header = array('typ' => 'JWT', 'alg' => 'RS256');
     $segments = array(apiUtils::urlSafeB64Encode(json_encode($header)), apiUtils::urlSafeB64Encode(json_encode($payload)));
     $signingInput = implode('.', $segments);
     $signer = new apiP12Signer($this->privateKey, $this->privateKeyPassword);
     $signature = $signer->sign($signingInput);
     $segments[] = apiUtils::urlSafeB64Encode($signature);
     return implode(".", $segments);
 }
Exemple #2
0
 private function makeSignedJwt($payload)
 {
     $header = array("typ" => "JWT", "alg" => "RS256");
     $segments = array();
     $segments[] = apiUtils::urlSafeB64Encode(json_encode($header));
     $segments[] = apiUtils::urlSafeB64Encode(json_encode($payload));
     $signing_input = implode(".", $segments);
     $signature = $this->signer->sign($signing_input);
     $segments[] = apiUtils::urlSafeB64Encode($signature);
     return implode(".", $segments);
 }