Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 539
Michaes Avatar asked Dec 15 '25 05:12

Michaes


1 Answers

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.

like image 160
diminishedprime Avatar answered Dec 16 '25 20:12

diminishedprime



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!