简体   繁体   English

Apps Script 和 Google Chat 的 OAuth 问题

[英]OAuth problem with Apps Script and Google Chat

I'm currently trying to make a google chat bot on Apps Script, using webhooks that supposedly don't require any authentification.我目前正在尝试使用不需要任何身份验证的 webhooks 在 Apps Script 上制作一个谷歌聊天机器人。 However, when I run my Apps Script function from Apps Script, it seems like I have to allow my account to "use external web apps" or something along these lines.但是,当我从 Apps Script 运行我的 Apps Script 功能时,似乎我必须允许我的帐户“使用外部网络应用程序”或类似的东西。 I developped the Apps Script as an API, so that I could call the functions from an external point, but it says that I need OAuth credentials to do so.我将 Apps 脚本开发为 API,以便我可以从外部调用函数,但它说我需要 OAuth 凭据才能这样做。 And I know how to implement OAuth credentials, I just have no idea what scope I'm supposed to use since webhooks are supposed to work without authentification.而且我知道如何实现 OAuth 凭证,我只是不知道我应该使用什么范围,因为 webhooks 应该在没有身份验证的情况下工作。

Here's the function:这是函数:

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);
}

okay I found the answer myself;好吧,我自己找到了答案;

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

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

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