Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return an more explicit error if the client is not authorized to send a request #112

Closed
szank opened this issue Apr 13, 2018 · 1 comment
Milestone

Comments

@szank
Copy link

szank commented Apr 13, 2018

Hi,
Could you please consider returning a more descriptive error when the account making an API request is not authorised to perform it.
For example if you want to list the queues via rabbithole API and there is a typo in the password/the permissions on RabbitMQ are not set correctly the error one would get is:
json: cannot unmarshal object into Go value of type []rabbithole.QueueInfo. This can be somewhat confusing.

When using curl the retrieved response is:

< HTTP/1.1 401 Unauthorized
< content-length: 50
< content-type: application/json
< date: Fri, 13 Apr 2018 13:31:57 GMT
< server: Cowboy
< vary: origin
<
* Connection #0 to host 127.0.0.1 left intact
{"error":"not_authorised","reason":"Login failed"}

I would suggest returning an "unauthorised" error message if the query response code is 401 on every request.

I am happy to create the PR, but right now I am quite pressed for time, so it would have to wait.

@michaelklishin
Copy link
Owner

Let's fold this into #116. A PR that demonstrates the approach would be welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants