如何在Google Cloud Function中使用GCP服务帐号?

ana*_*rce 1 google-cloud-platform google-cloud-functions

我有一个具有全域权限的 Google Cloud Platform 服务帐户。我可以从我的终端将其添加到 Google Analytics API 调用中,并且它可以正常工作。但是,我想运行与 Google Cloud Function 相同的脚本,并引用 GCP 中的服务帐户,而不在存储库或 GCP 之外的任何地方包含 client_secret_service_account.json 文件(如下所示)。那可能吗?

KEY_FILE_LOCATION = 'client_secret_service_account.json'
Run Code Online (Sandbox Code Playgroud)

man*_*uza 5

您现在可以在部署 Cloud Functions 时引用服务帐户。检查gcloud 的文档

使用 GCP 控制台时,展开“高级选项”以通知服务帐户