curl and jq 8 cheatsheet
curl and jq 8: Authentication and headers
5 common curl and jq 8 tasks.
Send a bearer token
Authenticate with a token from an environment variable.
curl -H "Authorization: Bearer $TOKEN" https://api.example.com/me
Use basic authentication
Send a username, with curl prompting for the password.
curl -u username https://api.example.com/me
Set a header
Send any request header you need.
curl -H "Accept: application/json" https://api.example.com/users
Save and send cookies
Store cookies in a file and send them on later requests.
curl -c cookies.txt -b cookies.txt https://example.com/login