【问题标题】:OAuth problem with Apps Script and Google ChatApps 脚本和 Google Chat 的 OAuth 问题
【发布时间】:2021-07-02 09:12:00
【问题描述】:

我目前正在尝试在 Apps Script 上制作一个谷歌聊天机器人,使用据称不需要任何身份验证的 webhook。 但是,当我从 Apps Script 运行我的 Apps Script 函数时,似乎我必须允许我的帐户“使用外部网络应用程序”或类似的东西。 我将 Apps 脚本开发为 API,以便我可以从外部调用这些函数,但它说我需要 OAuth 凭据才能这样做。而且我知道如何实现 OAuth 凭据,我只是不知道我应该使用什么范围,因为 webhook 应该在没有身份验证的情况下工作。

函数如下:

function sendText(text) {

  var url = "https://chat.googleapis.com/v1/spaces/[space]/messages?key=[webhook-key]&token=[token]";

  message = { 'text': text };
  var message_headers = {};


  const response = UrlFetchApp.fetch(url, {
    method: 'post',
    contentType: 'application/json',
    payload: JSON.stringify(message),
  });

  Logger.log(response);
}

【问题讨论】:

    标签: google-apps-script google-oauth google-chat


    【解决方案1】:

    好的,我自己找到了答案;

    范围是:https://googleapis.com/auth/script.external_request

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-31
      • 1970-01-01
      • 1970-01-01
      • 2019-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多