调查列表API不会返回资源字典

时间:2016-05-22 19:15:59

标签: google-surveys

试用Surveys API示例Python脚本," List Surveys"命令只返回request_id而不是"资源"具有预期调查列表的对象

执行示例脚本

  

surveyAPI.py --service_account --service_account_secrets_file certificate.json list

" list"的结果命令to_json方法:

{
  "body": null,
  "methodId": "consumersurveys.surveys.list",
  "resumable_uri": null,
  "headers": {
    "accept-encoding": "gzip,deflate",
    "accept": "application/json",
    "user-agent": "google-api-python-client/1.5.1 (gzip)"
  },
  "uri": "https://www.googleapis.com/consumersurveys/v2/surveys?alt=json",
  "resumable": null,
  "body_size": 0,
  "resumable_progress": 0,
  "method": "GET",
  "_in_error_state": false,
  "response_callbacks": []
}

执行list命令的响应 - no" resources"广告的对象。

{
  u'requestId': u'5742026000ff0e1cfc8a2e45010001737e3430322d747269616c320001707573682d30352d32302d7230380001013d'
}

我的帐户中有大约150个调查。此命令在API资源管理器中工作正常,我可以使用下一页令牌链来查看列表。

我做错了什么?

1 个答案:

答案 0 :(得分:2)

您似乎正在尝试使用服务帐户列出您帐户所拥有的调查问卷。为此,您需要将服务帐户作为所有者添加到您帐户所拥有的资源中。这里有关于此过程的更多信息: How can I allow a user to get access to survey results using the Google Consumer Surveys API?

或者,您可以设置3脚OAuth客户端密钥,并将其与示例脚本一起使用。这将提示您以常规非服务帐户登录并使用这些凭据。请参阅https://developers.google.com/identity/protocols/OAuth2WebServer进行设置。

然后您可以使用具有此凭据的客户端。 ./example_client.py list --client_secrets_file

如果您使用示例脚本,请确保将凭据配置为重定向到localhost:8080。