我正在创建一个应用程序,要求用户从其云端硬盘中选择一个文件夹。我正在努力设置 Picker API。
遵循本文档我使用他们的“Hello World”脚本设置了我的项目,但在更改“devlopedKey”和“clientID”后,我测试代码以接收错误:
错误 401,invalid_client,没有注册源。
经过搜索后,我发现了将客户端凭据中的授权 JavaScript 来源设置为http://本地主机:8888。执行此操作后,我收到一个不同的错误:
错误 400,起源_不匹配
抱歉,如果这是我的一个简单错误,任何帮助将不胜感激。
您必须专门为 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)