Dynamic Bearer Token In API Bridge

Do you deal with expiring bearer tokens in API Bridge, that require manual token generation and data source updates for retrieving data into sheets? The Dynamic bearer token option simplifies this process. It automatically generates a new token through an API call you specify, and uses it to fetch the data for you. Let’s walk through an example to understand how this works:

Note: Currently, this option only supports endpoints that allow GET requests to refresh the token.

Example Scenario: Express Retail API Integration

We’ll illustrate using the Express Retail API to fetch customer-related data. This API requires an initial access token generated via an API key. Subsequent API calls for data retrieval need to use this newly generated access token. Let’s automate this by automatically generating the access token using the API key and using it in other API calls.

1. Setting up the Data Source

  • Go to Menu -> Data sources -> Click on the “Add” button.
  • Fill in the data source details:
    • Base URL: https://api.retailexpress.com.au/v2.1
    • Authorization: Dynamic Bearer token
    • Token Authentication URL: /auth/token
      (Suffix URL of Retail Express API’s Authorization endpoint)
    • Access token name: access_token
      (Field name containing the new access token in the Authorization API’s response)
    • Headers:
    • x-api-key: API_KEY (Your API key)
  • Save the data source

2. Creating a Query

  • Go to Menu -> Data queries -> Click on the “Add” button.
  • Name your query and select the created data source.
  • Fill in the query details:
    • Method: GET
    • URL Path/Suffix: /customers
      (This is the URL suffix path to retrieve customer data from Retail Express API)
    • JSON Processors: JmesPath
    • JMES Path: data
      (Picks out necessary data from the API’s response. In this case, the value with the name”data”)
  • Select the desired sheet and cell in the Result section at the bottom

Now, running the query will automatically use the specified Authorization endpoint from the data source to generate a new bearer token. And it will then run the query with the new token, pulling customer data and writing it to the Sheet.

This method simplifies the process by automatically generating a bearer token using specified Authorization endpoint and removes the need of manual updates to the data source.

We hope this feature is beneficial. If you have any more questions or need help, don’t hesitate to reach out by creating a support ticket here.

Tags: , ,

Was this helpful?