biigle / core

:large_blue_circle: Application core of BIIGLE
https://biigle.de
GNU General Public License v3.0
12 stars 15 forks source link

API Status code for wrong authentication #642

Closed dlangenk closed 1 year ago

dlangenk commented 1 year ago

If you use wrong credentials you get a 302 status code and get redirected to biigle login. This makes sense for the website, but shouldn't the rest api return a 401 unauthorized? This makes handling of errors more complicated as endpoints might also return a 302 as a correct response (for example the get file endpoint).

mzur commented 1 year ago

You get the "scriptable" status codes if you set the header Accept: application/json. You get this with the API wrapper script. Otherwise, the API returns responses meant for the browser (as it uses the same API).