How to…

Automate DADI API authentication in Paw

EDGE Network
Edge
2 min readApr 17, 2018

--

Paw, much like Postman, is an app for interacting with REST APIs. Unlike Postman, however, it’s a native Mac OS app and does have a one-off cost of £39.99 (~$55 USD) — but the designer in me prefers Paw’s more polished interface so I’m happy to spend the money (you may be too, now, as Paw is offering a 20% discount to DADI users).

So, just as Eduardo’s productivity hack helped automate authentication in Postman, this tip will save you the pain of having to refresh your Bearer token frequently when working with DADI API. Except with Paw, it’s even easier.

Setting up the token fetch

The first thing you want to do after setting up your DADI API is to create a request to the /token endpoint. With my development API running locally on http://127.0.0.1:8081, the token endpoint is available at http://127.0.0.1:8081/token.

The key steps are:

  1. Make sure your DADI API is running
  2. Set the method to POST
  3. Make sure the endpoint is /token (unless you specifically changed it in API)
  4. In Body > JSON set your clientID and secret key/values.
  5. Send the request using ⌘ + Enter or the refresh icon.

If successful you will receive a JSON response containing an access token, similar to the below image:

The DADI API token fetch correctly configured

Copy the returned access token

In the response pane on the right side you should see accessToken returned along with some other properties.

Right-click the accessToken cell and select Copy as Response Body Dynamic Value.

Copy the accessToken

Fetching one of your collections

The final step is to make any other request to the API. Here, I’m fetching some articles:

  1. Click the + bottom left to create a new request
  2. Type in your desired endpoint e.g., http://127.0.0.1:8081/1.0/cloud/articles
  3. In Headers create a new header named Authorization. The value field should contain Bearer then paste the copied value from the previous step.

The value should read Bearer [Response Parsed Body: Your request name ► accessToken]. And in the raw request view below you should see the value resolved to the actual token.

The API should now authenticate and return results

That’s it, the authentication step will now take place automatically whenever you perform a new request. You can repeat the steps to continue creating API requests.

Written by David Longworth. David is the Design Director at DADI.

--

--

EDGE Network
Edge
Editor for

Peer-to-peer serverless infrastructure, powered by blockchain technology and built using the spare capacity all around us. The future of the cloud is Edge.