Skip to content

Instantly share code, notes, and snippets.

@cagataygurturk
Created February 23, 2020 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cagataygurturk/ed602b8a915ccfdc0c0c5acd5d75460b to your computer and use it in GitHub Desktop.
Save cagataygurturk/ed602b8a915ccfdc0c0c5acd5d75460b to your computer and use it in GitHub Desktop.
Invoking Cloud Function
const url = 'https://REGION-HOST_PROJECT_ID.cloudfunctions.net/FUNCTION_NAME';
const targetAudience = url;
const {GoogleAuth} = require('google-auth-library');
const auth = new GoogleAuth();
async function request() {
 const client = await auth.getIdTokenClient(targetAudience);
 const res = await client.request({url});
 console.info(res.data);
}
request().catch(err => {
 console.error(err.message);
 process.exitCode = 1;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment