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:
Make sure your DADI API is running
Set the method to POST
Make sure the endpoint is /token (unless you specifically changed it in API)
In Body > JSON set your clientID and secret key/values.
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:
🔗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.
🔗Fetching one of your collections
The final step is to make any other request to the API. Here, I’m fetching some articles:
Click the + bottom left to create a new request
Type in your desired endpoint e.g., http://127.0.0.1:8081/1.0/cloud/articles
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.
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.