Skip to content

Instantly share code, notes, and snippets.

@anderson-marques
Created April 19, 2021 13:59
Show Gist options
  • Save anderson-marques/45e11db3411700c10950fd32bc02879e to your computer and use it in GitHub Desktop.
Save anderson-marques/45e11db3411700c10950fd32bc02879e to your computer and use it in GitHub Desktop.
Create GCP Access token for Service Accounts
const {google} = require('googleapis');
const main = async function() {
const auth = new google.auth.GoogleAuth({
keyFile: __dirname + '/service-account-key.json',
scopes: [ 'https://www.googleapis.com/auth/cloud-platform']
});
const accessToken = await auth.getAccessToken()
console.log(JSON.stringify(auth, null, 4))
console.log(JSON.stringify(accessToken, null, 4))
}
main().then().catch(err => console.log(err))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment