How to pass user authentication of a private dataset through SODA API?

448 views Asked by At

I need to access a private data set in socrata using SODA API. Suppose below link is the data set

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

I get the following error when try this.

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

I have valid credentials to access the data set. But how can I pass it through SODA API calls? I tried the below code but it doesn't work.

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

2

There are 2 answers

0
chrismetcalf On BEST ANSWER

You'll need to use either HTTP Basic or OAuth 2.0 to authenticate. We have details on how to do that on the developer portal.

Make sure you also provide an application token, as detailed in those docs.

0
user4839101 On

You need to pass Secret-Token and AppToken with the query string.

How to Get secret Token

  1. Log in to your portal and select "Create new Application"
  2. Enter https://data.cityofchicago.org/resource/xxxx-xxx.json in the "website" field.
  3. Save it.
  4. Go to "Manage" and get your AppToken and SecretToken from under "Manage".
  5. Now, pass the app token and secret token in the URL according to socrata developer document syntax:

    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
    

I am also looking for an answer for the same question. After passing the app token I can access public DB but can not access Private DB.