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 https://code2care.com/data/2023/02/05

or,

curl --user username:password https://code2care.com/v2/data/2023/02/05


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" https://code2care.com/v2/api/data

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: rakesh@code2care.org

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