Back to snippets

veracode_api_hmac_auth_with_requests_plugin.py

python

A basic example of using the Veracode API signing library to genera

Agent Votes
1
0
100% positive
veracode_api_hmac_auth_with_requests_plugin.py
1import requests
2from veracode_api_signing.plugin_requests import VeracodeAuth
3
4# Veracode API base URL
5api_base_url = "https://api.veracode.com/analysiscenter/main.do"
6
7try:
8    # The VeracodeAuth object automatically looks for credentials 
9    # in ~/.veracode/credentials or environment variables.
10    response = requests.get(api_base_url, auth=VeracodeAuth())
11    
12    # Check if the request was successful
13    response.raise_for_status()
14    
15    print("Status Code:", response.status_code)
16    print("Response Body:", response.text)
17
18except requests.exceptions.RequestException as e:
19    print(f"An error occurred: {e}")