# Postman collection

To make it easier for merchants to integrate with our API, we have created a Postman collection that you can use to generate a BankId OIDC Token and create, and display test QR codes.

To use the Postman Collection, you will need to have obtained the `client_id` and `client_secret` from us. [(Read more)](https://docs.stoe.no/id-card/getting-started/authentication.md)

[Download Postman Collection](https://docs.stoe.no/id-card/assets/idcard-in-bankid-app-postman-collection.json)

### Setting up the Postman Collection

- _Import the Collection:_
  Open Postman, select 'Import,' and import the collection you downloaded from the link above. Alternatively, you can drag and drop the collection.json file into the Postman window.

- _Fill in missing `client_id`, `client_secret` and the`scope` parameters in the body of the ID-card Test POST as shown bellow:_
  ![Filling in missing client_id, and client_secret](https://docs.stoe.no/id-card/assets/img/postman/postman1.jpg)

> **The value for `scope` must be one that you have permission to use. Any other value will result in an error.**

- _Add QR code visualization to the Post-Response script of the ID-card Test GET request to display the QR code:_

Visualization script:

```javascript
   const jsonData = pm.response.json()
   pm.visualizer.set(`
      <body>
      <img id="ItemPreview" width="200" height="200" src="">
      <p>time-to-live: ${jsonData.ttl}</p>
      <p>createdAt(epoch): ${jsonData.ts}</p>
      </body>
      <script>
      document.getElementById("ItemPreview").src = "data:image/png;base64, ${jsonData.qrCode}";
      </script>
   `);
```

![Filling in missing script](https://docs.stoe.no/id-card/assets/img/postman/postman2.jpg)

### Using the Postman Collection

1. Make a call to the ID-card Test POST with `client_id`, `client_secret`, and `scope` to recieve an `access_token` in the response.
2. Use the ID-card Test GET request with the `access_token` set in the Authorization field using Bearer Token Auth.
3. Check the Visualize tab in the Body section to see the QR code.

Screenshots of the steps above.

Step 1
![step 1](https://docs.stoe.no/id-card/assets/img/postman/postman3.jpg)

Step 2
![step 2](https://docs.stoe.no/id-card/assets/img/postman/postman4.jpg)

Step 3
![step 3](https://docs.stoe.no/id-card/assets/img/postman/postman5.jpg)
