无法验证部署ID

时间:2018-02-06 14:22:36

标签: google-data-studio

我想学习如何为google data studio创建API连接器。我跟着"开始"分步计划(https://developers.google.com/datastudio/connector/get-started#use_the_community_connector)创建我的第一个连接,但是因为我继续在google datastudio中收到以下错误而导致卡住了#34; 无法检索连接器清单或是无效的。检查连接器,然后重试"

Beneath是我使用的代码(直接从上述URL复制)加上manifestfile

var API_KEY = "AIzaSyDq6tFxmFAzzo_-u2nxHjbdia_yUGfk-mA";

function getConfig(request) {
  var config = {
    configParams: [
      {
        type: "INFO",
        name: "connect",
        text: "This connector does not require any configuration. Click CONNECT at the top right to get started."
      }
    ]
  };
  return config;
};

var fontDataSchema = [
  {
    name: 'family',
    label: 'Font Family',
    dataType: 'STRING',
    semantics: {
      conceptType: 'DIMENSION'
    }
  },
  {
    name: 'category',
    label: 'Font Category',
    dataType: 'STRING',
    semantics: {
      conceptType: 'DIMENSION'
    }
  },
  {
    name: 'count',
    label: 'Count',
    dataType: 'NUMBER',
    semantics: {
      conceptType: 'METRIC',
      isReaggregatable: true
    }
  }
];

function getSchema(request) {
  return {schema: fontDataSchema};
};

function getData(request) {
  var dataSchema = [];
  request.fields.forEach(function(field) {
    for (var i = 0; i < fontDataSchema.length; i++) {
      if (fontDataSchema[i].name === field.name) {
        dataSchema.push(fontDataSchema[i]);
        break;
      }
    }
  });

  var url = [
    'https://www.googleapis.com/webfonts/v1/webfonts?sort=alpha&fields=items(category%2Cfamily)&key=',
    API_KEY];
  var response = JSON.parse(UrlFetchApp.fetch(url.join(''))).items;

  var data = [];
  response.forEach(function(font) {
    var values = [];
    dataSchema.forEach(function(field) {
      switch(field.name) {
        case 'family':
          values.push(font.family);
          break;
        case 'category':
          values.push(font.category);
          break;
        case 'count':
          values.push(1);
          break;
        default:
          values.push('');
      }
    });
    data.push({
      values: values
    });
  });

  return {
    schema: dataSchema,
    rows: data
  };
};

function getAuthType() {
  var response = {
    "type": "NONE"
  };
  return response;
}

以及以下清单文件:

    {
      "dataStudio": {
        "name": "Google Fonts Metadata",
        "company": "Awesome Developer",
        "logoUrl": "https://www.gstatic.com/images/branding/product/1x/google_fonts_48dp.png",
        "addonUrl": "https://developers.google.com/datastudio/connector/getstarted",
        "supportUrl": "https://developers.google.com/datastudio/connector/faq",
        "description": "This connector uses the Google Fonts Developer API to retrieve metadata for all font families served by Google."
      }

}

由于某些原因,我无法验证部署ID。任何人都可以弄清楚我做错了什么。

亲切的问候,

保罗(诺布)

1 个答案:

答案 0 :(得分:1)

我解决了这个问题。原来这是一个权限问题和帐户问题。当我使用其他帐户登录并请求访问时,问题已解决。