Uses JavaScript's CryptoJS library within a Postman Pre-Request script to: parse the request-body, create a SHA256 HMAC signature, build the Miva JSON API's authorization HTTP Header, and add the header to the current Postman request.
- Navigate to the "Miva Admin > Settings > Users > API Tokens"
- Edit a token
- Create a Postman Environmental Variable called
API_Token
that is set to the "Edit API Token > Access Token" value - Create a Postman Environmental Variable called
API_SigningKey
that is set to the "Edit API Token > Signature" value
- Edit a request in Postman
- Switch to the "Scripts" tab of the request
- Switch to the "Pre-request" code
- Populate it with
01__standalone-pre-request-script.js
- Open the Postman > Package Library
- Edit a request in Postman
- Switch to the "Scripts" tab of the request
- Switch to the "Pre-request" code
- Click the "Open package library" link
- Create a "New Package"
- Populate it with
02__package--source.js
- "Save" your package
- Edit a request in Postman
- Switch to the "Scripts" tab of the request
- Switch to the "Pre-request" code
- In the "Packages" search-dropdown, select your package
- Require and use your package like it is done in
03__package--pre-request-script.js
- https://docs.miva.com/developer/developer-resources/json-api/api-getting-started/
- https://learning.postman.com/docs/tests-and-scripts/write-scripts/postman-sandbox-api-reference/
- https://learning.postman.com/docs/tests-and-scripts/write-scripts/package-library/
- https://www.postman.com/postman/postman-answers/request/xy5m1mu/sha256?tab=scripts
- https://cryptojs.gitbook.io/docs#documentation