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: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

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