title: Cannot get signed url to work with gcloud storage
body: <p>Cannot get signed url to work with gcloud storage.</p>
  
  <p>I know there is probably something simple that's missing here but I can't find it.</p>
  
  <p>Trying to create a signed url to a file in a gcloud bucket following the directions here <a href="https://cloud.google.com/storage/docs/access-control/create-signed-urls-program" rel="nofollow">https://cloud.google.com/storage/docs/access-control/create-signed-urls-program</a></p>
  
  <p>Created a servive account and downloaded the pk12 and converted p12 to pem to get the key.</p>
  
  <p>Here is code:</p>
  
  <pre><code>$pkeyid = "-----BEGIN RSA PRIVATE KEY-----
  [removed actual key]
  -----END RSA PRIVATE KEY-----";
  $secret = "notasecret";
  $expires = time()+86400;
  $http_method = "GET";
  $bucketName = "mybucketname";
  $stringtosign = "GET\n
  \n
  text/plain\n
  ".$expires."\n
  \n
  \n
  \n
  ".$bucketName ."/mymediafile.mp4";
  
  openssl_sign($stringtosign, $signature, $pkeyid);
  $emailid="serviceaccount@[project].iam.gserviceaccount.com";    
  $signature = urlencode(base64_encode($signature));
  $gcloudloc = "https://storage.googleapis.com/".$bucketName ."/mymediafile.mp4?GoogleAccessId=".$emailid."&amp;Expires=".$expires."&amp;Signature=".$signature;
  </code></pre>
  
  <p>I get what looks like a valid signiture, but when I try to use the full url I get</p>
  
  <pre><code>The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.
  </code></pre>