【发布时间】:2018-12-20 12:38:38
【问题描述】:
我正在使用 KEY Auth 类型创建 Google Data Studio 连接器。根据谷歌文档,我的编程如下
function getAuthType() {
return {
type: 'KEY',
helpUrl: 'https://integra.jivrus.com/data-studio-connectors/insightly'
};
}
但是,Data Studio 不会提示用户在任何地方输入 KEY。因此会导致身份验证错误,因为 API 需要提供 KEY。
我该如何解决这个问题? KEY Auth Type 是否有任何工作示例代码?
我与KEY Auth Type相关的完整代码供参考。
var KEY_SIGNATURE = "dscc.key";
function getAuthType() {
return {
type: 'KEY',
helpUrl: 'https://integra.jivrus.com/data-studio-connectors/insightly'
};
}
function resetAuth() {
var userProperties = PropertiesService.getUserProperties();
userProperties.deleteProperty(KEY_SIGNATURE);
}
function isAuthValid() {
var userProperties = PropertiesService.getUserProperties();
var key = userProperties.getProperty(KEY_SIGNATURE);
return validateKey(key);
}
function setCredentials(request) {
var key = request.key;
var validKey = validateKey(key);
if (!validKey) {
return {
errorCode: 'INVALID_CREDENTIALS'
};
}
var userProperties = PropertiesService.getUserProperties();
userProperties.setProperty(KEY_SIGNATURE, key);
return {
errorCode: 'NONE'
};
}
function validateKey(key) {
return true;
}
感谢您的帮助。
【问题讨论】:
标签: google-apps-script google-data-studio