Skip to content

Commit

Permalink
wip: debug headers
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Oct 25, 2023
1 parent d4bbe3f commit ce4acf9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/api-demo-1-list-projects.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import os

from snyk import SnykClient
from utils import get_default_token_path, get_token
Expand All @@ -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:")
Expand Down
2 changes: 2 additions & 0 deletions snyk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions snyk/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

import requests

import logging


logger = logging.getLogger(__name__)

class SnykError(Exception):
pass


class SnykHTTPError(SnykError):
def __init__(self, resp: requests.Response):
logger.debug(resp.headers)
if hasattr(resp, "json"):
try:
data = resp.json()
Expand Down

0 comments on commit ce4acf9

Please sign in to comment.