将Google表格重定向到Google表格中的功能

问题描述

我正在尝试将 URL 重定向到google-sheets中的功能,该功能稍后应执行一些工作。

据我所知,我应该使用部署为wep应用为此功能创建一个 API ,然后使用此URL。

所以我要做的是创建2个包含此代码的脚本文件Api.gs

function test() {
  Logger.log('Success!!')
}

这应该是我将为其创建api的那个。

一个文件Authentication.gs包含此代码功能

showSideBar() {
    var authorizationUrl = 'https://www.upwork.com/ab/account-security/oauth2/authorize?redirect_uri=The_Api_URL_generated_for_the_function_above&client_id=clientID&response_type=token';
    var template = HtmlService.createTemplate(
        '<a href="<?= authorizationUrl ?>" target="_blank">Press here to authroze</a>.');
    template.authorizationUrl = authorizationUrl;
    var page = template.evaluate().setTitle('Authroize');
    SpreadsheetApp.getUi().showSidebar(page); 
}

显示一个侧边栏,当我按链接时,它可以正确地重定向我,但出现错误Missing or invalid redirect_uri parameter value

我正在尝试验证工作,并将其重定向到Google工作表 再次

所以我想知道做错了什么?还是我在做甚至有可能?

解决方法

尝试一下:

将其输入脚本编辑器并运行showmysidebar(),然后单击按钮,然后在右下角看到该吐司。

function test() {
  SpreadsheetApp.getActive().toast("Success");
}

function showmysidebar() {
  var html='<input type="button" value="test" onclick="google.script.run.test();" />';
  SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutput(html));
}