google-apps-script - 将谷歌表格重定向到谷歌表格中的函数
问题描述
我正在尝试将URL重定向到google-sheets中的一个函数,该函数稍后应该做一些工作。
所以据我了解,我应该使用Deploy as wep app为这个函数创建一个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
.
我正在尝试验证 upwork 并将其再次重定向到 google-sheets
所以我想知道我做错了什么?或者如果我正在做甚至可能?
解决方案
尝试这个:
将其输入脚本编辑器并运行 showmysidebar() 然后单击按钮并看到 toast 出现在右下角。
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));
}
推荐阅读
- r - How do I calculate two separate means for a vector with both characters and numbers?
- python - Calling python multiprocessing map function with a dictionary
- vue.js - How to prevent a submit button on a form to be clicked multiple times in VUEJS
- c++ - C++ 在填充数组时遇到问题
- javascript - discord.js detect multiple channel deletes and multiple bans
- python - 为什么不应用 pandas join-on-join 后缀
- arrays - Julia 截断数组数组的内部维度
- python - Jupyter QtConsole 在哪里保存它过去的命令
- python-3.x - Odoo 12:AttributeError:“int”对象没有属性“get”
- java - Gradle 无法使用 lombok 构建