Google 具有 KEY 身份验证类型的 Data Studio 连接器无法正常工作
Google Data Studio Connector with KEY Auth Type not working
我正在创建一个 Google 具有 KEY 身份验证类型的 Data Studio 连接器。根据 Google 文档,我编程如下
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;
}
感谢您的帮助。
如果 isAuthValid()
始终 return 为真,则永远不会显示提示。如果您将代码中的 validateKey(key)
更改为 return false,您将开始看到提示。
我正在创建一个 Google 具有 KEY 身份验证类型的 Data Studio 连接器。根据 Google 文档,我编程如下
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;
}
感谢您的帮助。
如果 isAuthValid()
始终 return 为真,则永远不会显示提示。如果您将代码中的 validateKey(key)
更改为 return false,您将开始看到提示。