可以使用Google API完成Google Apps脚本的所有操作吗?

可以使用Google API完成Google Apps脚本的所有操作吗?

问题描述:

我注意到Google Apps脚本编辑器使用Bearer令牌来发出很多请求,这使我想到:是否可以使用您的google API来完成使用google apps脚本完成的所有功能自己的服务器?本质区别是什么?仅仅是Google Apps脚本可以在google服务器上运行的事实,而使用google API时,您需要创建自己的服务器?

I noticed that the Google Apps Script editor uses a Bearer token to make requests for a lot of things, that got me thinking: Is it possible to do all functions that are done with the google apps script with the google API on your own server? What is the essential difference? Just the fact that google apps script runs on google servers, while with the google API you would need to create your own servers?

例如,许多文档功能(我认为只能通过API完成)可以在以下位置找到

For example many of the document functions, which I thought could only be done with the API, turns out can be found here https://developers.google.com/docs/api/reference/rest/v1/documents/request#InsertInlineImageRequest

那么本质区别是什么?

事实上Google Apps脚本可以在google服务器上运行,而使用google API则需要创建自己的服务器?

Just the fact that google apps script runs on google servers, while with the google API you would need to create your own servers?

是的.两种方法都有优点:

Yes. There are advantages to both methods:

  • 这是一个REST API.您可以在服务器中使用自己的语言(例如:Python).
  • api更具包容性. api可以完成某些工作,而应用程序脚本则无法完成这些工作.
  • 用户可以设置使用API​​的有限范围.
    • 例如,在Drive API上,https://www.googleapis.com/auth/drive.file可用于Drive API.使用应用程序脚本的DriveApp不能完成相同的操作.
    • It's a rest API. You can use your own language(eg: Python) in your servers.
    • The api is more inclusive. There are stuff which can be done with the api, which cannot be accomplished with apps script.
    • User can set limited scopes for using API.
      • For example, at Drive API, https://www.googleapis.com/auth/drive.file can be used for Drive API. The same cannot be done with DriveApp of apps script.
      • 没有服务器在您身边
      • 触发器.您可以将函数设置为在onEdit,onOpen或特定时间运行.
      • 与Google应用程序的深度集成:边栏/模式对话框只能使用应用程序脚本来完成.
      • 可以通过承载令牌间接访问api的所有方法.
      • 授权/身份验证由应用程序脚本处理.您不需要设置oauth.