Skip to content

Commit

Permalink
[Exchanges] handle oauth keys
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Oct 23, 2024
1 parent a5d1b07 commit b5da49a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Trading/Exchange/bitmart/bitmart_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 5 additions & 2 deletions Trading/Exchange/coinbase/coinbase_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit b5da49a

Please sign in to comment.