Node.js code for GET Request Basic Server Authentication Example
This Node.js code snippet was generated automatically for the GET Request Basic Server Authentication example.<< Back to the GET Request Basic Server Authentication example
What is HTTP?
Hypertext Transfer Protocol (HTTP) is a network protocol for exchanging data between multiple network devices, widely used to transfer data between an HTTP client (browser or mobile application) and a server. Currently, the HTTP protocol is the most popular and primary communication method on the Internet. HTTP is built on messages called request (request) and response (response) and is based on the client-server architecture. The client application generates a request and sends it to the server, after which the server processes this request, generates a response, and sends it back to the client.
What is HTTP Authentication?
HTTP Authentication is the process of authorizing a user to access a protected resource. Authentication is performed by sending credentials in the Authorization header to gain access to the resource. HTTP Authentication works like this: the client sends a request to the server for a specific page. The server responds to the client with a 401 (Unauthorized) status code and provides information on how to authenticate. The client then sends another request, including the Authorization header with the credentials. If the certificates are valid, the server responds with the requested page or API resource or a 403 (Forbidden) status code if the credentials are invalid.
What is Basic Server Authentication?
The Basic Server Authentication is an authentication method that sends the base64 encoded string to the server with the username and password in the Authorization header. For basic HTTP authentication, the request contains a header field in the form Authorization: Basic {credentials}, where the credentials are Base64 encoded login and password, concatenated with a single colon ":" For security reasons, basic server authentication should only be used over HTTPS/SSL.
Basic Server Authentication Syntax
The following is the syntax of the Authorization header:
Where:
- Authorization: standard HTTP authorization header
- Basic: indicates HTTP Authorization type
What is GET request?
GET is one of nine popular HTTP request methods. HTTP GET is used to request resources from the server, such as HTML pages, images, files, and JSON data. GET requests should only receive data do not change the server's state. GET requests cannot have a body, but you can still send data to the server in URL parameters (the maximum URL length limits the data size).