Michaes
Michaes

Reputation: 73

Google Data Studio Connector with KEY Auth Type not working

I am creating a Google Data Studio Connector with KEY Auth Type. As per Google Documentation, I have programmed as below

function getAuthType() {
  return {
    type: 'KEY',
    helpUrl: 'https://integra.jivrus.com/data-studio-connectors/insightly'
  };
}

However, Data studio is not prompting the user to enter KEY anywhere. So it is resulting in an authentication error as the API requires KEY to be supplied.

How do I solve this? Is there any working sample code for KEY Auth Type?

My full code related to KEY Auth Type is below for reference.

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;
}

Appreciate your help.

Upvotes: 3

Views: 836

Answers (1)

Matt Hamrick
Matt Hamrick

Reputation: 789

If isAuthValid() always returns true, then the prompt will never be shown. If you change validateKey(key) in your code to return false, you'll start seeing the prompt.

Upvotes: 3

Related Questions