Using Veracode APIs with Bruno requires initial configuration of either HMAC or OAuth credentials. Below are instructions for getting up and running with Veracode APIs in Bruno.
If you have not does so, please follow these steps to generate the necessary API Token Credential to use with Bruno.
- Generate API credentials for your Veracode user.
- Store the credential information in a safe place or as a credential file for use with Veracode products.
- Install Bruno on your machine.
- Create a Collection.
- In the Script tab paste in the code from bruno-pre-request-script.js and click the save button.
- Create a new Environment for the Veracode platform.
- Update the following variables as type secret
- api_id : (set to your Veracode API ID)
- api_key : (set to your Veracode API Key)
- Be sure to save
- In the collection (left nav) add and save a new request.
By default the script signs requests with HMAC (see above). To use an OAuth bearer token instead, add these variables to the Bruno environment:
| Variable | Type | Value |
|---|---|---|
| veracode_auth_type | plain | oauth (hmac or unset keeps HMAC) |
| oauth_veracode_client_id | secret | your OAuth client ID |
| oauth_veracode_client_secret | secret | your OAuth client secret |
api_id and api_key are not needed in oauth mode. The credentials are looked up in the same order as api_id and api_key: collection environment, global/workspace environment, process env, then secret manager.
How it works:
- The base URL is taken from the request URL (for example
https://api.veracode.com). The script requests a token from<base URL>/api/authn/v2/oauth2/token(client_credentialsgrant) and sendsAuthorization: Bearer <token>. - Your client ID and secret are only sent to
httpshosts on the default port that are underveracode.com,veracode.euorveracode.us. A request to any other host stops with an error before any credential is read. - The token is cached in Bruno runtime variables (memory only) and reused until 60 seconds before it expires. There is one cache slot, so a request to a different base URL (for example
api.veracode.euafterapi.veracode.com) or a different client ID fetches a new token. If two environments use the same base URL and client ID but different secrets, a token cached from one is reused for the other until it expires or Bruno restarts. - If the token request fails, the request stops with an error. There is no fallback to HMAC.
See the LICENSE for details