Cheatsheet Pages / curl Cheatsheet

How to use Basic auth with curl — -u

The endpoint wants a username and password.

curl -u admin:s3cret https://api.example.com/secure
# equivalent: -H "Authorization: Basic YWRtaW46czNjcmV0"

Good to know

-u builds the Authorization: Basic header for you — the commented line in the cheatsheet shows the equivalent header.

curl Cheatsheet one-page card — commands that actually work
The full one-page card — curl Cheatsheet. Get the complete cheatsheet on GitHub