Blog

Authenticate Akamai APIs in Postman

December 20, 2019 · by Javier Garza ·

Postman is a staple of API development and API exploration used by more than 8 million developers worldwide. A couple of years ago, Jeff Costa published an excellent blog that explained how you could leverage Postman to test Akamai APIs. This gave Postman users an easy way to learn how to use and work with Akamai’s APIs.

Recently, our Akamai engineers teamed up with Postman to make working with Akamai APIs even easier! The Postman app now supports the Akamai Authentication model when you update your Postman instance to the latest version of the native app. This added feature makes it simple to explore and use Akamai OPEN APIs without using kludgy pre-request scripts.

In this blog post, I’ll explain how you can quickly get started using Akamai APIs in Postman. Then we’ll dive into an example using Akamai’s Diagnostics API, which allows Akamai users to diagnose common issues users experience when delivering content to end-users. 

Here is what you’ll need:

  • Akamai API credentials (AKA Edgegrid). Check the API getting started for information on how to create these credentials.

  • Download the latest Postman version or you can check for updates within the app. Jus click the Postman Menu > Check for Updates. Once you’re up to date, it should look like this:

up to date version

It’s a good practice to use different sets of API credentials for different automation workflows. When you assign unique credentials to each workflow, you don’t risk breaking other workflows when your credentials are updated. 

Keeping separate sets of credentials also helps with security. Akamai API identity management allows you to fine-tune access controls to link a given API credential to a specific API endpoint. You can also specify unique control groups within your organization  to ensure robust access controls (for example, an API credential can only purge the cache for a specific website). 

Now, let’s dive into an example:

The Akamai Edgegrid credential that I am going to use in this example uses our Diagnostics API to run diagnostic tools like cURL, DIG, and MTR from Akamai Edge servers around the world.

When setting up our APIs on Postman, you’ll need your Akamai Edgegrid credentials. Our set of credentials consist of four fields: Client Secret, Host, Access Token, and Client Token. 

It should look something like this (but with your own credentials):

client_secret = HB6YJ3SPk8awNgTH7KmiJgIBFakEXF45AVB+c8rcW3I=

host = akab-c7ln4yeddxyewqiv-ifefakebarxcfgbp.luna.akamaiapis.net

access_token = akab-ixtlr7fakesfivyg-prd2scgasglgba

client_token = akab-l4d26umi6fakelz-3mrblddseykj4pg4

The Akamai CLI can also be used to access your API credentials via the .edgerc file that contains all of your credentials. 

If you use this file, note that there are many credentials. You can identify the credentials you need by looking at the section name within the square brackets, as you can see highlighted below. 

[akamai-diagnostics]

client_secret = HB6YJ3SPk8awNgTH7KmiJgIBFakEXF45AVB+c8rcW3I=

host = akab-c7ln4yeddxyewqiv-ifefakebarxcfgbp.luna.akamaiapis.net

access_token = akab-ixtlr7fakesfivyg-prd2scgasglgba

client_token = akab-l4d26umi6fakelz-3mrblddseykj4pg4

Set up your credentials in Postman:

Once you have your credentials, you’ll need to add them into Postman. Here’s how:

1. Create a new environment: Click the Manage Environment icon located on the top right corner and click Add. 

manage environments

2. Name your environment (ex: akamai-diagnostics), and add your credentials as variables. Press Add to save.  

input credentials

3. Select your environment from the Environments drop-down.

select environment

Set up your authorization:

In this example, we’ll call the List Available Ghost Locations endpoint, which will return the Edge Server locations where you can run diagnostic calls.

4. In the Postman app, press the orange New button, select Request and name your request (ex. Get Locations Edgegrid).

5. In the URL field, paste: https://{{host}}/diagnostic-tools/v2/ghost-locations/available

6. Next, go to the Authorization tab and select Akamai Edgegrid from the drop-down menu.

authorize

7. Now, you can input your credentials by referencing the variables you created earlier. For example in the “Access Token” field enter: {{access_token}}

input variables

Make your API call:

Now that we’ve input our credentials and set up our Akamai EdgeGrid authorization, we’re ready to send our request.

8. Press the blue Send button. The response body will populate with the ids for locations in which you can run diagnostic calls on Akamai Edge Servers. 

response body

And Voila! You’ve successfully authorized Postman to return data from Akamai APIs. 

Now you can copy and paste any of the location IDs to use in future API requests to resolve DNS entry or to run connectivity checks from specific locations all over the world. 

Pro tip: You can create a Postman Collection and save a series of requests that you can run in a specified order using monitors or in a CI/CD pipeline. Here is a sample collection I created in a couple of minutes that contains four diagnostic API calls that you can import into your Postman instance. 

 

Javier Garza Javier Garza is a developer evangelist at Akamai Technologies where he helps the largest companies on the internet run fast and secure apps by leveraging web performance, security and DevOps best practices. His life’s motto is: share what you learn, and learn what you don’t.