Curl/Bash code for Curl Bearer Token Authorization Header ExampleThis Curl/Bash code snippet was generated automatically for the Curl Bearer Token Authorization Header example.
<< Back to the Curl Bearer Token Authorization Header example
What is Curl?
Curl is a well-known command-line tool for transferring data between servers, designed to work without user intervention. Curl can upload or download data using popular protocols including HTTP, HTTPS, SCP, SFTP, and FTP with Curl. Curl is used for API testing, has built-in support for proxies, SSL, HTTP cookies. Curl runs on Linux, Windows, and macOS platforms.
What is the Authorization Header?
HTTP provides a built-in framework for controlling access and authentication to protected resources. The authorization request header contains the credentials for authenticating the HTTP client to the server. The most commonly used authorization headers are Basic Auth and Bearer Token headers.
What is the Bearer Authorization Token?
HTTP provides a user authentication framework to control access to protected resources. Bearer authentication (also called token authentication) is done by sending security tokens in the authorization header. The Bearer Token is a string that is not intended to be used by clients. Some servers will issue bearer tokens, short lines of hexadecimal characters, while others may use structured tokens like JWTs. The client must send this token back to the server in every authorization header when requesting protected resources.
How to send Curl request with Bearer Authorization Header?
The Bearer Token can be sent in the Curl request header. To pass the bearer token in the Curl authorization header, add the following command line parameter when executing the Curl request:
How to send Curl POST request with Bearer Token Authorization Header?
Sending the Bearer Token with a Curl POST request is similar to sending the Bearer Token with a Curl GET request. POST data is passed with the -d command-line option, and the authorization header and the bearer token are passed with the -H command-line option.
- -X, --request: HTTP method to use when communicating with the server
- -H, --header: HTTP headers to send to the server with a POST request
- -d, --data: Data to be sent to the server using a POST request