knowm / XChange

XChange is a Java library providing a streamlined API for interacting with 60+ Bitcoin and Altcoin exchanges providing a consistent interface for trading and accessing market data.
http://knowm.org/open-source/xchange/
MIT License
3.82k stars 1.93k forks source link

Getting Signature for this request is not valid. (HTTP status code: 400) #4716

Open nftguruai opened 1 year ago

nftguruai commented 1 year ago

Any idea why I am getting the following error? I have checked the API keys and everything works when I try the binance.us api directly and get the trades.

org.knowm.xchange.binance.dto.BinanceException: Signature for this request is not valid. (HTTP status code: 400)


    ExchangeSpecification exSpec = new BinanceUsExchange().getDefaultExchangeSpecification();
    exSpec.setApiKey("myapikeygoeshere");
    exSpec.setSecretKey("mysecretkeygoeshere");

    BinanceUsExchange binance = (BinanceUsExchange) ExchangeFactory.INSTANCE.createExchange(exSpec);
    Instrument instrument = new CurrencyPair("MANA","USD");
     TradeService tradeService = binance.getTradeService();
    try {
        UserTrades userTrades = tradeService.getTradeHistory(new BinanceTradeHistoryParams(instrument));
        System.out.println(userTrades.toString());
    } catch (IOException e) {
        e.printStackTrace();
    }

Screenshot 2023-04-22 at 11 44 07 PM
ElCrebel commented 1 year ago

Hello, i tested version 5.0.1 - 5.0.14 and got the same error, i think it is most likely with the signature, or the way they are being passed in the request. Hmmm do you know a fix?