1
votes

I am trying to use the @google-cloud client library to authenticate using a service account. Is there a way to pass in the keyfile content as a JSON object rather than a file path? I don't want to store the key file on the server, rather use a secrets manager service, load the key file in memory and use it as needed. The library seems to only take key file path:

const storage = new Storage({projectId:projectId, keyFilename: keyPath});

1

1 Answers

3
votes

Use the credentials parameter in the constructor: storageOptions

var sa_data = fs.readFileSync(keyPath);
var sa_json = JSON.parse(sa_data)

const storage = new Storage({
  credentials: sa_json
});