Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)

I'm trying to access the Google Cloud API from an AWS Lambda function but I don't know how to authenticate. The auth guide in the Google Cloud documentation ( wants me to download a credentials JSON file and use Application Default Credentials, but as anyone who has used hosted functions already knows, the point is that you don't need to manage a server or runtime environment, so Lambda doesn't give me the ability to store arbitrary files in the environment of the running code. 

I can use the Cloud SDK locally to get an access token but it expires so I can't use it in my function as a permanent solution.

Is there not a way I can get an access token that I can use indefinitely in my code to call the Google Cloud API? Is there any other solution?

1 Answer

0 votes
by (44.4k points)

Instead of saving the credentials in a JSON file, you can hard-code them as said in this documentation.

This example calls the Language API:

var language = require('@google-cloud/language')({

  projectId: '',

  credentials: {

      client_email: '',

      private_key: '',




language.detectEntities('Axel Foley is from Detroit').then(function(data) {

  var entities = data[0];

  var apiResponse = data[1];


Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.6k answers


108k users

Browse Categories