How to pass authorization header using cURL

You can pass the authorization header using the cURL command as follows.

For Basic Auth:

curl -u username:password


curl --user username:password

For OAuth 2 with Bearer Token:

Though this is not a header (-H) but an option to be used when the authentication is of type Basic.

curl -H "Authorization: Bearer the_token"

cURL Command with Authorization

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap