Closed cdupont closed 3 years ago
I checked the code and if you call it this way, it will work:
$ curl -X GET "http://wazigate.local/devices" -H "accept: application/json" -H "Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJjbGllbnQiOiI2MDE3Yzc0Zjc4NDUyNDAwMDYwMzYwYTgiLCJleHAiOjE2MTg4NDg0NTF9.TnlSoNOYNTs9E1T9soB3CXuc9ZI-w4OwLZE0hdGO3rc"
A complete example:
TOKEN=`curl -X POST "http://wazigate.local/auth/token" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"username\":\"admin\",\"password\":\"loragateway\"}" | tr -d '"'`
curl -X GET "http://wazigate.local/devices" -H "accept: application/json" -H "Token: $TOKEN"
Thanks. The HTTP standard seems to use "Authorization: Bearer XXX": https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization
Yes I guessed so, I will improve it to make it standard
Fixed
This is tested here: https://github.com/Waziup/WaziGate/blob/master/tests/tests.py#L61 and working:)
$ curl -X GET "http://wazigate.local/devices" -H "accept: application/json" -H "Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJjbGllbnQiOiI2MDE3Yzc0Zjc4NDUyNDAwMDYwMzYwYTgiLCJleHAiOjE2MTg4NDg0NTF9.TnlSoNOYNTs9E1T9soB3CXuc9ZI-w4OwLZE0hdGO3rc"
Hello guys, I am facing the same problem of unauthorized error. I tried your solution, but I still have the same issue. Can you please help me ?
Using Authorization bearer is not working. However, Cookie header is working.