PHP code for POST JSON Bearer Token Authorization Header Example
This PHP code snippet was generated automatically for the POST JSON Bearer Token Authorization Header example.<< Back to the POST JSON Bearer Token Authorization Header example
What it JSON?
JSON (JavaScript Object Notation) is a lightweight text-based, language-independent data exchange format that specifies formatting rules for the portable representation of structured data. JSON is self-describing, easy to understand, and language independent. JSON is used for client/server communication in web and mobile applications.
What is HTTP POST?
The HTTP POST method is the most commonly used of the nine standard Hypertext Transfer Protocol (HTTP) methods. The POST method requests the webserver to receive and process the data contained in the body of the POST message. The POST request is usually used when submitting an HTML form or when uploading data to a server. Unlike GET and HEAD requests, the HTTP POST requests may change the server state.
What is Bearer Authentication?
HTTP provides a framework for user authentication to control access to protected resources. Bearer authentication (token authentication) is done by sending security tokens in the authorization header. You can do bearer authentication with any programming language. The Bearer Token is a string with no meaning or uses but becomes important within a proper tokenization system. The server usually generates the bearer token in response to a login request and saves it in the browser or local storage. For security reasons, the bearer token should only be sent over HTTPS (SSL) connections.
Bearer Token Authentication Syntax
Below is the syntax of the Bearer Token Authentication header:
How to send JSON request with Bearer Token Authentication?
The following is an example of making a POST JSON request with a Bearer Token authentication header: