コード例 #1
0
 /**
  * Creates a signed JWT.
  * @param array $payload
  * @return string The signed JWT.
  */
 private function makeSignedJwt($payload)
 {
     $header = array('typ' => 'JWT', 'alg' => 'RS256');
     $payload = json_encode($payload);
     // Handle some overzealous escaping in PHP json that seemed to cause some errors
     // with claimsets.
     $payload = str_replace('\\/', '/', $payload);
     $segments = array(GoogleGAL_Utils::urlSafeB64Encode(json_encode($header)), GoogleGAL_Utils::urlSafeB64Encode($payload));
     $signingInput = implode('.', $segments);
     $signer = new GoogleGAL_Signer_P12($this->privateKey, $this->privateKeyPassword);
     $signature = $signer->sign($signingInput);
     $segments[] = GoogleGAL_Utils::urlSafeB64Encode($signature);
     return implode(".", $segments);
 }