title: Node.js google cloud storage authentication using credentials token
body: <p>I'm trying to authenticate with google cloud storage using a credentials token.
  Can't find an example anywhere in the node.js GCS api docs on how to do so.
  They instruct to generate and download a json file that contains your private key and then link to its path on your file system like so:</p>
  <pre><code>const storage = new Storage({keyFilename: &quot;key.json&quot;});
  </code></pre>
  <p>And this works just fine.</p>
  <p>However I don't want to save my key as a JSON file, but create the credentials and save them as environment variables something like so:</p>
  <pre><code>const gc = new Storage({
      credentials: {
        client_email: process.env.CLIENT_EMAIL,
        private_key: process.env.SECRET_KEY
      }
  });
  </code></pre>
  <p>I tried getting this token from the settings of the bucket, from the interoperability menu, using service account HMAC access keys.</p>
  <p><a href="https://i.stack.imgur.com/8Jbos.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8Jbos.png" alt="I tried getting this token from the settings of the bucket, from the interoperability menu, using service account HMAC access keys" /></a></p>
  <p>When I try to upload/delete files from the bucket with the authentication method above I get the following error:</p>
  <p>Error: error:0909006C:PEM routines:get_name:no start line</p>
  <p>Appreciate any help on the matter</p>