burakoner / OKX.Api

Up-to-date, most-complete, well-organized, well-documented, easy-to-use, multi-task and multi-thread compatible OKX Cryptocurrency Exchange Rest and Websocket Api Wrapper
MIT License
39 stars 15 forks source link

Error in using new version #1

Closed overstartup closed 1 year ago

overstartup commented 1 year ago

I upgrade to a new version, but I have this error. my configuration:

   api= new OKXRestApiClient(new OKXRestApiClientOptions { DemoTradingService = configurationOptions.DemoTradingService, LogLevel = LogLevel.Trace });
            api.SetApiCredentials(ConfigurationOptions.ApiKey, ConfigurationOptions.SecretKey, ConfigurationOptions.Passphrase); 

23/04/13 20:46:47:908 | Information | OKX RestApi | [1] Creating request for https://www.okx.com/api/v5/account/balance 2023/04/13 20:46:47:911 | Trace | OKX RestApi | [1] Sending GET signed request to https://www.okx.com/api/v5/account/balance with headers Accept=[application/json] 2023/04/13 20:46:48:143 | Warning | OKX RestApi | [1] Error received in 229ms: {"msg":"Request header OK-ACCESS-KEY can not be empty.","code":"50103"}

other methods:

2023/04/13 20:58:14:223 | Information | OKX RestApi | [3] Creating request for https://www.okx.com/api/v5/account/positions-history 2023/04/13 20:58:14:226 | Trace | OKX RestApi | [3] Sending GET signed request to https://www.okx.com/api/v5/account/positions-history?instId=BTC-USDT-SWAP&instType=SWAP&limit=2 with headers Accept=[application/json] 2023/04/13 20:58:14:491 | Warning | OKX RestApi | [3] Error received in 262ms: {"msg":"Request header OK-ACCESS-KEY can not be empty.","code":"50103"}

2023/04/13 20:58:14:737 | Information | OKX RestApi | [1] Creating request for https://www.okx.com/api/v5/trade/order 2023/04/13 20:58:14:741 | Trace | OKX RestApi | [1] Sending POST signed request to https://www.okx.com/api/v5/trade/order with request body '{"ccy":"USDT","clOrdId":"638170162944971801","instId":"BTC-USDT-SWAP","ordType":"market","posSide":"long","side":"buy","sz":"100","tag":"538a3965e538BCDE","tdMode":"cross"}' with headers Accept=[application/json] 2023/04/13 20:58:15:012 | Warning | OKX RestApi | [1] Error received in 268ms: {"msg":"Request header OK-ACCESS-KEY can not be empty.","code":"50103"}

I checked your example, too, it has the same issue. I haven't check all method yet. Please check to find all issues.

alekved commented 1 year ago

I have the same error on private requests, for example

2023/04/14 01:21:45:831 | Information | OKX RestApi | [10] Creating request for https://aws.okx.com/api/v5/trade/order 2023/04/14 01:21:46:320 | Warning | OKX RestApi | [10] Error received in 481ms: {"msg":"Request header OK-ACCESS-KEY can not be empty.","code":"50103"}

All credentials provided to the API are correct. I just switched to the new version from OKEx.Net, and there were no such errors in the older package, I used it a few hours ago.

I'd appreciate if you check this issue and publish the solution.

alekved commented 1 year ago

It seems the error is in Authentication/OkxAuthenticationProvider.cs, function AuthenticateRestApi(). In the first check point (line 22) we can see

if (!signed || !options.SignPublicRequests)

must be

if (!signed && !options.SignPublicRequests)

burakoner commented 1 year ago

Yes It's my mistake. I'm updating it now. I'll release new version this evening

burakoner commented 1 year ago

New Release https://github.com/burakoner/OKX.Api/commit/da27018a20640b5e5ba2186311d54b3359569355 and https://www.nuget.org/packages/OKX.Api/1.0.3