From 895dcfa89b0b64e176cd1e148fed32b41e2c3ef3 Mon Sep 17 00:00:00 2001 From: Skylar Saveland Date: Fri, 14 May 2021 16:04:17 -0700 Subject: [PATCH 1/2] Update public client - no auth --- cbpro/public_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cbpro/public_client.py b/cbpro/public_client.py index e854a163..f484dadc 100644 --- a/cbpro/public_client.py +++ b/cbpro/public_client.py @@ -266,7 +266,7 @@ def _send_message(self, method, endpoint, params=None, data=None): """ url = self.url + endpoint r = self.session.request(method, url, params=params, data=data, - auth=self.auth, timeout=30) + timeout=30) return r.json() def _send_paginated_message(self, endpoint, params=None): @@ -296,7 +296,7 @@ def _send_paginated_message(self, endpoint, params=None): params = dict() url = self.url + endpoint while True: - r = self.session.get(url, params=params, auth=self.auth, timeout=30) + r = self.session.get(url, params=params, timeout=30) results = r.json() for result in results: yield result From 3f44c49ff72b24470e60488d43642548bf14f66c Mon Sep 17 00:00:00 2001 From: Skylar Saveland Date: Fri, 14 May 2021 16:32:31 -0700 Subject: [PATCH 2/2] could be more elegant but let's try this --- cbpro/public_client.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cbpro/public_client.py b/cbpro/public_client.py index f484dadc..64f387b5 100644 --- a/cbpro/public_client.py +++ b/cbpro/public_client.py @@ -265,8 +265,12 @@ def _send_message(self, method, endpoint, params=None, data=None): """ url = self.url + endpoint + if self.auth is not None and not all([ + self.auth.api_key, self.auth.passphrase, self.auth.secret_key, + ]): + self.auth = None r = self.session.request(method, url, params=params, data=data, - timeout=30) + auth=self.auth, timeout=30) return r.json() def _send_paginated_message(self, endpoint, params=None): @@ -295,8 +299,13 @@ def _send_paginated_message(self, endpoint, params=None): if params is None: params = dict() url = self.url + endpoint + + if self.auth is not None and not all([ + self.auth.api_key, self.auth.passphrase, self.auth.secret_key, + ]): + self.auth = None while True: - r = self.session.get(url, params=params, timeout=30) + r = self.session.get(url, params=params, auth=self.auth, timeout=30) results = r.json() for result in results: yield result