Use of Service account credentials when using Cloud Functions Shell

谁说我不能喝 提交于 2020-07-22 21:32:35

问题


I've just migrated to Cloud Functions 1.0 and am trying out Cloud Functions shell/emulator to run functions locally (using instructions at https://firebase.google.com/docs/functions/local-emulator)

One of the functions is using code below to upload a file to cloud storage and then then generate url for it....but am getting following error:

SigningError: Cannot sign data without client_email.

const bucket = gcs.bucket(bucketName);

bucket.upload(localFilePath, {destination: destinationPath})
    .then(data => {
      const file = data[0];
      return file.getSignedUrl({
        action: 'read',
        expires: '01-01-2099'
      });

I can work around this locally by explicitly setting keyFileName as shown below but seems like this should not be necessary

const gcs = require('@google-cloud/storage')({keyFilename: 'service-account.json'});

The link above mentions that "Cloud Firestore and Realtime Database triggers already have sufficient credentials, and do not require additional setup" (I'm triggering this code from db write). I'm setting GOOGLE_APPLICATION_CREDENTIALS env variable in any case but doesn't look like it's picking it up.

来源:https://stackoverflow.com/questions/49840780/use-of-service-account-credentials-when-using-cloud-functions-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!