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

Set the User-Agent

Send a custom User-Agent header.

curl -A "my-script/1.0" https://example.com

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

Was this page helpful?