diff --git a/examples/api-demo-1-list-projects.py b/examples/api-demo-1-list-projects.py index 2ffbfc2..79c86a1 100755 --- a/examples/api-demo-1-list-projects.py +++ b/examples/api-demo-1-list-projects.py @@ -1,4 +1,5 @@ import argparse +import os from snyk import SnykClient from utils import get_default_token_path, get_token @@ -17,7 +18,7 @@ def parse_command_line_args(): args = parse_command_line_args() org_id = args.orgId -client = SnykClient(token=snyk_token) +client = SnykClient(token=os.getenv('PYSNYK_TOKEN'), debug=True, tries=1, delay=2, backoff=2) for proj in client.organizations.get(org_id).projects.all(): print("\nProject name: %s" % proj.name) print(" Issues Found:") diff --git a/snyk/client.py b/snyk/client.py index e3fa329..ae33dbf 100644 --- a/snyk/client.py +++ b/snyk/client.py @@ -175,6 +175,8 @@ def get( fkwargs = {"headers": self.api_headers} logger.debug(f"GET: {debug_url}") + headers_no_token = [value for key, value in self.api_headers.items() if key not in ["Authorization"]] + logger.debug({"headers": headers_no_token, "params": params}) resp = retry_call( self.request, diff --git a/snyk/errors.py b/snyk/errors.py index dc0fc03..e0e509b 100644 --- a/snyk/errors.py +++ b/snyk/errors.py @@ -2,6 +2,10 @@ import requests +import logging + + +logger = logging.getLogger(__name__) class SnykError(Exception): pass @@ -9,6 +13,7 @@ class SnykError(Exception): class SnykHTTPError(SnykError): def __init__(self, resp: requests.Response): + logger.debug(resp.headers) if hasattr(resp, "json"): try: data = resp.json()