Data Studio身份验证:checkForValidCreds和validateCredentials之间的区别

问题描述

在Data Studio身份验证文档(https://developers.google.com/datastudio/connector/auth)上,有两个功能需要定义,我对此感到困惑。

在setCredentials函数中,它说要调用一个checkForValidCreds函数

  // Optional
  // Check if the provided username and token are valid through a
  // call to your service. You would have to have a `checkForValidCreds`
  // function defined for this to work.
  var validCreds = checkForValidCreds(username,token);

同时,在isAuthValid函数中,要求您定义一个类似的函数,称为validateCredentials:

  // This assumes you have a validateCredentials function that
  // can validate if the userName and token are correct.
  return validateCredentials(userName,token);

这些用户定义的函数是否彼此不同?如果是这样,定义它们时我需要知道什么区别?

解决方法

auth page中列出了唯一需要常量的函数名称。与您的问题相关,只要您定义isAuthValid(),您就应该行得通。 checkForValidCredsvalidateCredentials只是isAuthValid()内部使用的同一方法的两个实现。只要在isAuthValid()中正确引用了这些名称,您就可以命名这些名称。