0

我需要使用 SODA API 访问 socrata 中的私有数据集。假设下面的链接是数据集

https://data.cityofchicago.org/resource/xxxx-xxx.json

尝试此操作时出现以下错误。

"error" : true,
"message" : "You must be logged in to access this resource"

我拥有访问数据集的有效凭据。但是我怎样才能通过 SODA API 调用传递它呢?我尝试了下面的代码,但它不起作用。

https://data.cityofchicago.org/resource/xxxx-xxx.json ?$username='myname'&$password='pwd@123'

4

2 回答 2

0

您需要使用HTTP BasicOAuth 2.0进行身份验证。我们在开发人员门户上提供了有关如何执行此操作的详细信息

确保您还提供了应用程序令牌,如这些文档中所述。

于 2015-06-18T17:24:27.867 回答
0

您需要使用查询字符串传递 Secret-Token 和 AppToken。

如何获取秘密令牌

  1. 登录到您的门户并选择“创建新应用程序”
  2. https://data.cityofchicago.org/resource/xxxx-xxx.json在“网站”字段中输入。
  3. 保存。
  4. 转到“管理”并从“管理”下获取您的 AppToken 和 SecretToken。
  5. 现在,根据 socrata 开发者文档语法在 URL 中传递应用令牌和秘密令牌:

    https://sandbox.socrata.com/oauth/access_token
    ?client_id=YOUR_AUTH_TOKEN
    &client_secret=YOUR_SECRET_TOKEN
    &grant_type=authorization_code
    &redirect_uri=YOUR_REDIRECT_URI
    &code=CODE
    

也在寻找相同问题的答案。传递应用程序令牌后,我可以访问公共数据库但无法访问私有数据库。

于 2015-07-14T21:02:31.220 回答