Bruno - an open source alternative to Postman

Bruno is an API client tool very similar to Postman. It’s open source, file based and offline only. Your data resides on your device. It comes as standalone desktop app, CLI tool and a VSCode extension for syntax checking .bru files.

The website can be found here: https://www.usebruno.com/

Porting your ISC Postman collection is a a five minute task. Here is a quick guide on how to port the V3 collection from Postman to Bruno Desktop app.

  1. Download and install the desktop app from here: Downloads

  2. Export one of the ISC collections (e.g. V3) from Postman:

  1. Import the collection into Bruno (chose Postman collection during import dialogue)

Screenshot 2024-03-12 at 10.22.40

  1. Under Collection Settings, set the Auth type to “No Auth” and paste the following Pre Request script into the Script setting:
const axios = require("axios");
const clientId = bru.getEnvVar("clientId");
const clientSecret = bru.getEnvVar("clientSecret");
const baseUrl = 'https://' + bru.getEnvVar("tenant") + '.api.' + bru.getEnvVar("domain") + '.com';
const tokenUrl = baseUrl + '/oauth/token';

console.log("Entering collection pre-request script");

if (!bru.getEnvVar("baseUrl")) {
  console.log("Initialising baseUrl");
  bru.setEnvVar("baseUrl",baseUrl);
}

var moment = require("moment");
if (!bru.getEnvVar("tokenExpTime")) {
  console.log("Initialising tokenExpTime");
  bru.setEnvVar("tokenExpTime",moment());
}

if (moment(bru.getEnvVar("tokenExpTime")) <= moment() || !bru.getEnvVar("tokenExpTime") || !bru.getEnvVar("accessToken") ) {
  var time = moment();
  time.add(12, 'hours');
  bru.setEnvVar("tokenExpTime", time);

  try {
    console.log("Requesting Access Token");
    let response = await axios({
      method: 'POST',
      url: tokenUrl,
      headers: {
            'Content-Type': 'multipart/form-data',
        },
        data: {
            grant_type: 'client_credentials',
            client_id: clientId,
            client_secret: clientSecret
        },
    });
    bru.setEnvVar("accessToken", response.data.access_token);
  
  } catch (error) {
    throw error;
  }
} else {
  console.log("No need to renew");
}
  1. Configure a new environment with the following Variables (You only need to enter valid values for domain, clientId, clientSecret, and tenant.
    The others will be set in the Pre-Request script.) :

  1. Pick a request and execute:

Have fun with Bruno.

7 Likes

I was under the impression that we don’t talk about Bruno? :stuck_out_tongue:

1 Like