简体   繁体   English

使用 Google Cloud API 测试 Google Apps 脚本

[英]Testing Google Apps Script using Google Cloud APIs

I am working on implementing a Google App Script project which makes use of various cloud APIs like Big Query, Cloud SQL, Google Ads etc. Implementation works pretty well through a project where GCP project ID is configured.我正在实施一个 Google App Script 项目,该项目使用各种云 API,如 Big Query、Cloud SQL、Google Ads 等。通过配置 GCP 项目 ID 的项目实施效果很好。

But I would like to have a development only version which I can use for my validation.但我想要一个仅供开发的版本,可用于我的验证。

If I use a test deployment as mentioned on https://developers.google.com/apps-script/add-ons/how-tos/testing-editor-addons , it works.如果我使用https://developers.google.com/apps-script/add-ons/how-tos/testing-editor-addons中提到的测试部署,它就可以工作。 But this works only via the script project where GCP project is configured.但这仅适用于配置 GCP 项目的脚本项目。 For other, it gives "Google developers console API activation" error.对于其他,它会给出“Google 开发人员控制台 API 激活”错误。

So question here is - is it mandatory to provide the GCP project ID even for test deployments?所以这里的问题是——是否必须为测试部署提供 GCP 项目 ID? Is there any configuration that I can use for getting around this problem?有什么配置可以用来解决这个问题吗?

Please note - I can always create a test deployment from the production version of App Script project (where GCP project id is added).请注意 - 我始终可以从 App Script 项目的生产版本(其中添加了 GCP 项目 ID)创建测试部署。 But I would like to maintain 2 versions possibly without having to add GCP project in development version.但我想维护 2 个版本,而不必在开发版本中添加 GCP 项目。

Kindly advice.好心的建议。

It depends on how you or your team have designed the solution.这取决于您或您的团队如何设计解决方案。 Also it's depends on if the solution is requiring users to authorize all the scopes, if it's using a service account, among other factors.此外,这还取决于解决方案是否要求用户授权所有范围,是否使用服务帐户等因素。

One design might be based on the use of a single Google Cloud Platform standard project to handle all the OAuth authorizations.一种设计可能基于使用单个 Google Cloud Platform 标准项目来处理所有 OAuth 授权。

Another design might be based on using two or more Google Cloud Platform projects.另一种设计可能基于使用两个或多个 Google Cloud Platform 项目。 IE you could use a default project for Google Apps Script and a standard project another for the Google APIs like BigQuery. IE,您可以为 Google Apps 脚本使用默认项目,为 Google API(如 BigQuery)使用另一个标准项目。 This setup might require the use of a service account.此设置可能需要使用服务帐户。

Related有关的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM