I keep getting a 401 response when I try to use authentication = ApiKeyAuthentication() in my ModelResource. I looked at Django Tastypie: How to Authenticate with API Key and he uses the get parameters to solve his issue. If I try use get parameters it picks up username but not api_key!
This works in browser
http://127.0.0.1:8000/api/v1/spot/8/?username=darren&api_key=9999d318e43b8055ae32d011be5b045ad61dad50
Sending via curl in terminal doesn't pickup api_key parameter
curl --dump-header - http://127.0.0.1:8000/api/v1/spot/8/?username=darren&api_key=9999d318e43b8055ae32d011be5b045ad61dad50
Why when using curl and appending 2 querystring parameters like ?username=darren&api_key=9999d318e43b8055ae32d011be5b045ad61dad50
does it only pickup the first one. Is this not the correct way?
Windows user running curl binaries should use double-quotes instead of single quotes to get multiple query parameters command working.
Query parameters are passed after the URL string by appending a question mark followed by the parameter name , then equal to (“=”) sign and then the parameter value. Multiple parameters are separated by “&” symbol.
Typing &
in the command line means run the preceding command in the background (thanks @Maccesch), because of this anything after the &
is being treated as a new command.
Try wrapping the url in quotes.
curl --dump-header - "http://127.0.0.1:8000/api/v1/spot/8/?username=darren&api_key=9999d318e43b8055ae32d011be5b045ad61dad50"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With