Skip to content

Commit 7f5da05

Browse files
author
openclaw-bot
committed
feat(auth): prioritize client key basic auth over token
1 parent 662f7d6 commit 7f5da05

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎bootpay_backend/rest_client.py‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ class BootpayBackend:
1212
API_VERSION = '5.0.0'
1313
SDK_VERSION = '2.1.2'
1414

15-
def __init__(self, application_id, private_key, mode='production'):
15+
def __init__(self, application_id, private_key, mode='production', client_key=None, secret_key=None):
1616
self.application_id = application_id
1717
self.private_key = private_key
18+
self.client_key = client_key
19+
self.secret_key = secret_key
1820
self.mode = mode
1921
self.token = None
2022
self.api_version = self.API_VERSION
@@ -35,11 +37,15 @@ def set_api_version(self, version):
3537
# @returns ResponseForamt
3638
def __request(self, method='', url='', data=None, headers={}, params={}):
3739
auth_header = None
38-
if self.token is not None:
39-
auth_header = f"Bearer {self.token}"
40-
elif self.application_id and self.private_key:
41-
encoded = base64.b64encode(f"{self.application_id}:{self.private_key}".encode('utf-8')).decode('utf-8')
40+
if self.client_key and self.secret_key:
41+
encoded = base64.b64encode(f"{self.client_key}:{self.secret_key}".encode('utf-8')).decode('utf-8')
4242
auth_header = f"Basic {encoded}"
43+
elif self.application_id:
44+
if self.token is not None:
45+
auth_header = f"Bearer {self.token}"
46+
elif self.private_key:
47+
encoded = base64.b64encode(f"{self.application_id}:{self.private_key}".encode('utf-8')).decode('utf-8')
48+
auth_header = f"Basic {encoded}"
4349

4450
if method in ['put', 'post']:
4551
response = getattr(requests, method)(url, json=data, headers=dict(headers, **{

0 commit comments

Comments
 (0)