Postman with the Painless Analytics API

The following instructions will walk you through setting up Postman with the Painless Analytics API.

Before you begin, ensure you are signed into your account at painlessanalytics.com.

Setting up Postman and getting tokens

Visit the API Getting Started page in your account (must be signed in) for instructions how the Painless Analytics RESTful API and OAuth 2.0 authentication work.

Step 1 – Register a New Application

  • Navigate to the Your Applications page.
  • Click the “Register New App” button.
  • Enter your application’s name and the URL of your app.
  • Take note of your redirect URL for later use. You can retrieve it by editing your app in the “Your Applications” tab after registration.

For testing, we recommend using “http://localhost” for your applications URL. You can modify the URLs registered at any time.

Step 2 – Obtain Client Credentials

  • After registering, you will receive your ClientID and ClientSecret. Store these securely as you will need them for authorization and they cannot be retrieved later.

Step 3 – Configure Postman Authorization Tab

  • Open Postman and click the new tab button on the dashboard.
  • In the Authorization tab, select “OAuth 2.0” as the Type and “Request Headers” for adding authorization data.

Step 4 – Configure Token

  • Name your token and ensure the “Header Prefix” is set to “Bearer”.
  • Set the “Grant Type” to “Authorization Code”.
  • Enter your redirect URL (from step 1) into the “Callback URL” field in Postman. Ensure it matches exactly.
  • Add the “Auth URL” https://account.painlessanalytics.com/oauth/authorize and the “Access Token URL” https://account.painlessanalytics.com/oauth/token from the Getting Started page.
  • Input your clientID and clientSecret obtained from step 3.
  • Leave “Scope” blank and set a value for “State” (e.g., 0).
  • Set “Client Authentication” to “Send as Basic Auth Header”.

Step 5 – Obtain Tokens

  • Click “Get New Access Token” and sign in with your Painless Analytics credentials.
  • After logging in, proceed in Postman to view your token details. Securely store your accessToken and refreshToken.

Step 6 – Authorize in Swagger

  • Navigate to the Swagger documentation (location to be determined).
  • Click “Authorize” in the top right corner and paste your accessToken. Proceed by clicking the “close” button, and you should be good to go!

Using the refresh token to get a new access token

To obtain a new access token in Postman using a refresh token, follow these steps:

  • Create a new request in Postman where you want to refresh the token.
  • Set the request method to POST.
  • Specify the Token URLhttps://account.painlessanalytics.com/oauth/token
  • Configure the request paramters:
    • grant_type: refresh_token
    • refresh_token: refreshToken from steps above
    • client_id: your clientID
    • client_secret: your clientSecret
    • Set the Content-Type header: to application/x-www-form-urlencoded.
  • Click the “Send” button in Postman to send the request.
  • The API should respond with a new access token. You can then use this new access token for subsequent API calls.

Postman’s auto-refresh feature (optional but recommended)

Postman now offers an auto-refresh feature for OAuth 2.0 tokens. You can enable auto-refresh within the Authentication tab of your collection or request. Postman will automatically refresh your access token before it expires.

Postman’s manual refresh button

You can manually refresh the token by clicking the “Refresh” button within Postman, learn more.

To top