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

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!