Gmail Addon 与外部站点之间的通信

Communication between Gmail Addon and external site

我正在构建一个 Gmail 插件,用户需要对服务进行身份验证才能使用它。为此,我们有一个站点充当多种服务的代理(例如,Dropbox 和 Box)。它的工作方式是,用户选择一个服务进行身份验证,它被重定向到他们的 oauth 页面,当收到回调时,令牌在我们自己的服务上生成并发回我们的令牌,而不是他们的。

所以流量会是...

1. User clicks login on Gmail Add-on
2. Opens own site (third party) that contains multiple login options.
3. Selects one that redirects user inside it on a new oAuth service.
4. Our service (inside the open window) receives oAuth token and creates a new token.
5. This new token is sent back to add-on.

我想知道的是我如何 get/send/proceed 完成最后一步,一旦我们获得令牌,是否有办法将其发送回 gmail 附加组件?在其他平台上,我们可以读取重定向、发送套接字,但我不知道如何在 google 应用程序脚本上实现它。

有什么想法吗?

我所问的可以使用 class ScriptApp 实现。基本上,外部站点可以使用 usercallback 脚本来 return 令牌,因此流程将是:

  1. 生成回调状态。
  2. 发送带有状态令牌的redirect_uri。
  3. 您可以在此步骤(在外部网站上)做任何您想做的事。
  4. 在 url 参数中发回您需要的信息(在我的例子中是令牌)。
  5. 回调响应可以在您的回调操作中获得。