From b5da49a6b625fa3db73b0dde80b14ee60d03ccf8 Mon Sep 17 00:00:00 2001 From: Guillaume De Saint Martin Date: Wed, 23 Oct 2024 23:03:05 +0200 Subject: [PATCH] [Exchanges] handle oauth keys --- Trading/Exchange/bitmart/bitmart_exchange.py | 4 ++-- Trading/Exchange/coinbase/coinbase_exchange.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Trading/Exchange/bitmart/bitmart_exchange.py b/Trading/Exchange/bitmart/bitmart_exchange.py index ff8bc7579..ea8c12800 100644 --- a/Trading/Exchange/bitmart/bitmart_exchange.py +++ b/Trading/Exchange/bitmart/bitmart_exchange.py @@ -27,9 +27,9 @@ class BitMartConnector(exchanges.CCXTConnector): def _client_factory(self, force_unauth, keys_adapter=None) -> tuple: return super()._client_factory(force_unauth, keys_adapter=self._keys_adapter) - def _keys_adapter(self, key, secret, password, uid): + def _keys_adapter(self, key, secret, password, uid, auth_token): # use password as uid - return key, secret, "", password + return key, secret, "", password, None, None class BitMart(exchanges.RestExchange): diff --git a/Trading/Exchange/coinbase/coinbase_exchange.py b/Trading/Exchange/coinbase/coinbase_exchange.py index 34b4980c6..06a61353c 100644 --- a/Trading/Exchange/coinbase/coinbase_exchange.py +++ b/Trading/Exchange/coinbase/coinbase_exchange.py @@ -65,12 +65,15 @@ class CoinbaseConnector(ccxt_connector.CCXTConnector): def _client_factory(self, force_unauth, keys_adapter=None) -> tuple: return super()._client_factory(force_unauth, keys_adapter=self._keys_adapter) - def _keys_adapter(self, key, secret, password, uid): + def _keys_adapter(self, key, secret, password, uid, auth_token): + if auth_token: + # when auth token is provided, force invalid keys + return "ANY_KEY", "ANY_SECRET", password, uid, auth_token, "Bearer " # CCXT pem key reader is not expecting users to under keys pasted as text from the coinbase UI # convert \\n to \n to make this format compatible as well if secret and "\\n" in secret: secret = secret.replace("\\n", "\n") - return key, secret, password, uid + return key, secret, password, uid, None, None @_coinbase_retrier async def _load_markets(self, client, reload: bool):