title: Getting 403 forbidden when generating signed url with PUT request to upload an object to Google Cloud Storage
body: <p>I'm trying to give a temporary access to a service account that has only read permission to upload an mp3 to a Google Cloud Storage bucket.</p>
  
  <p>For that, I'm generating a <code>signedurl</code> but i can't get it to work.</p>
  
  <p>What I'm doing to generate the URL and upload the file : </p>
  
  <pre><code>const config = {
      action: 'write',
      expires: '03-12-2019',
      contentType: 'audio/mpeg'
  }
  
  const storage = new Storage({
      projectId: projectId,
      keyFilename: './service-account-key.json'
  })
  
  let bucketSubDirectory = storage.bucket(bucketName).file('subdirectory/in/bucket/' + songName)
  
  bucketSubDirectory.getSignedUrl(config, (err, url) =&gt; {
      if (err) {
          console.error(err)
          return
      }
      console.log(url)
      // The file is now available to be written to.
      let writeStream = request.put(url, {
         headers: {
          'Content-Type': 'audio/mpeg'
         }
      })
      writeStream.end('New data');
  
      writeStream.on('complete', function (resp) {
          console.log(resp.statusCode + " " + resp.statusMessage)
  
      })
  
  })
  </code></pre>
  
  <p>When I execute the script I get a <code>403 forbidden</code> response and when I try to access the generated URL from the browser I get the following : </p>
  
  <pre><code>&lt;Error&gt;
  &lt;Code&gt;MalformedSecurityHeader&lt;/Code&gt;
  &lt;Message&gt;Your request has a malformed header.&lt;/Message&gt;&lt;ParameterName&gt;signature&lt;/ParameterName&gt;
  &lt;Details&gt;Signature was not base64 encoded&lt;/Details&gt;
  &lt;/Error&gt;
  </code></pre>
  
  <p>Any idea how can I solve this problem?</p>