BTCMarkets / API

API
119 stars 30 forks source link

Respond with http status 401 instead of 200 when incorrect auth details are supplied #111

Closed camstuart closed 4 years ago

camstuart commented 6 years ago

Hi,

I'm writing a client in Go, a strongly typed language. (IE requires me to specify the request and response structures of 'structs' made up of primitive data types)

So when I make a request to an endpoint such as /account/balance I am expecting a particular json response structure such as:

[
   {
      "balance":1000000000,
      "pendingFunds":0,
      "currency":"AUD"
   },
   {
      "balance":1000000000,
      "pendingFunds":0,
      "currency":"BTC"
   },
   {
      "balance":1000000000,
      "pendingFunds":0,
      "currency":"LTC"
   }
]

Along with a 200 http status code

However, if I have not encoded the request correctly (an issue regarding timestamp at my end), I will get a response structure of:

{
   "success":false,
   "errorCode":1,
   "errorMessage":"Authentication failed. invalid timestamp"
}

But the http status code is still 200.

In this scenario I would expect a http status of 401. Which would allow me to decode the message structure accordingly.

Go requires the response json to conform to a declared struct type. In my software, I would like to decode the response json to a structure based on the response code.

200 -> decode message as expected 401 -> decode message with error style response and handle accordingly

justin-ngin commented 6 years ago

Hi @camstuart ,

Thanks for bringing this up. I'm adding it as a topic of consideration for our dev team, and I'll let you know (as well as update the documentation, if needed) as soon as I have an answer.

Regards, Justin

Yoosh94 commented 5 years ago

Is there an update on this issue? I have just started to use to API and find that I also get a 200 when my authentication is incorrect.

martin-nginio commented 4 years ago

Hi @camstuart and @Yoosh94

Thank you for your patience.

We are now releasing a new generation of API that is more compatible with REST guidelines in general (e.g. correct http status codes) and delivers several other improvements so I'd encourage you to take a look.

https://api.btcmarkets.net/doc/v3#section/Introduction

Thanks for your feedback agian.

Regards, Martin

martin-nginio commented 4 years ago

closing the issue.