How to authenticate to Google Cloud API without Application Default Credentials or Cloud SDK?

后端 未结 1 2050
星月不相逢
星月不相逢 2021-02-20 08:16

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 (https://cloud.goo

1条回答
  •  生来不讨喜
    2021-02-20 08:50

    I found how to hard-code the credentials without the need to save them in a JSON file. It was in this documentation here:

    https://googlecloudplatform.github.io/google-cloud-node/#/docs/language/0.7.0/guides/authentication

    Below is an example that 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];
    });
    

    0 讨论(0)
提交回复
热议问题