Skip to content

Instantly share code, notes, and snippets.

@rhyskentish
Created May 18, 2020 16:26
Show Gist options
  • Save rhyskentish/9eb5183014c0b598cdd3a984be093b20 to your computer and use it in GitHub Desktop.
Save rhyskentish/9eb5183014c0b598cdd3a984be093b20 to your computer and use it in GitHub Desktop.
const { SecretManagerServiceClient } = require('@google-cloud/secret-manager');
const secretManagerclient = new SecretManagerServiceClient();
const parent = 'projects/<YourProjectId>';
const tokenId = <YourTokenId>
async function getSecret() {
const [version] = await client.accessSecretVersion({
name: parent + '/secrets/' + tokenId + '/versions/latest',
});
// Extract the payload as a string.
return version.payload.data.toString('utf8');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment