gpt4 book ai didi

google-apps-script - Google Apps 脚本 - 在独立脚本上使用 Google 的文件选择器

转载 作者:行者123 更新时间:2023-12-01 22:17:13 24 4
gpt4 key购买 nike

我正在创建一个应用程序,要求用户从他们的云端硬盘中选择一个文件夹。我正在努力设置 Picker API。

Following this documentation我使用他们的“Hello World”脚本设置我的项目,但在更改“devlopedKey”和“clientID”后,我测试代码以接收错误:

错误 401,invalid_client,没有注册来源。

四处搜索后,我发现建议将客户端凭据中的授权 JavaScript 来源设置为 http://localhost:8888 .这样做后我收到一个不同的错误:

错误 400,origin_mismatch

抱歉,如果这是我的一个简单错误,我们将不胜感激。

最佳答案

您必须专门为 google apps 脚本设置 Origin。

var picker = new google.picker.PickerBuilder()
// Instruct Picker to display only spreadsheets in Drive. For other
// views, see https://developers.google.com/picker/docs/#otherviews
.addView(google.picker.ViewId.SPREADSHEETS)
// Hide the navigation panel so that Picker fills more of the dialog.
.enableFeature(google.picker.Feature.NAV_HIDDEN)
// Hide the title bar since an Apps Script dialog already has a title.
.hideTitleBar()
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(pickerCallback)
//THIS IS THE IMPORTANT LINE FOR YOU
.setOrigin(google.script.host.origin)
// Instruct Picker to fill the dialog, minus 2 pixels for the border.
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);

这是文档:https://developers.google.com/apps-script/guides/dialogs#file-open_dialogs

关于google-apps-script - Google Apps 脚本 - 在独立脚本上使用 Google 的文件选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44188017/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com