Java code for Authorization Bearer Header Example
This Java code snippet was generated automatically for the Authorization Bearer Header example.<< Back to the Authorization Bearer Header example
What is HTTP?
HTTP is a network data transfer protocol used to transfer data between HTTP clients (browsers, mobile apps, etc.) and servers. HTTP is based on a client-server architecture and built on messages called requests and responses. The client generates a request and sends it to the server, where the server processes this request and generates a response by sending it back to the client.
What is the Authorization Header?
The Authorization request header includes credentials to authenticate the client on the server. HTTP provides a built-in framework for user authentication and controlling access to protected resources.
What is Bearer Authorization?
Bearer Authentication (also called token authentication) is a mechanism used to authorize clients by sending a security token with every HTTP request we make to the server. The server usually generates a bearer token in response to a login request and sends it to the client. The client stores it on the user's device (for example, the browser can save the token in local storage). The client sends the bearer token back to the server on every request to the protected resource (in the Authorization header).
Bearer Token Authorization Syntax
Following is the syntax for sending a request with an Authorization Bearer Header:
Where:
- Authorization: standard HTTP authorization header
- Bearer: indicates a bearer token authorization scheme
How to send a request with Bearer Authorization Header?
Below is an example HTTP POST request with a Bearer Token authentication header that we send to the echo ReqBin URL: