Sobes.tech
Senior

What is authentication? How does a Bearer token work?

sobes.tech AI

Answer from AI

Authentication is the process of verifying the identity of a user or system, confirming that the user is indeed who they claim to be.

Bearer token is a type of access token used for authentication in APIs. The client receives the token after a successful login and then includes it in the HTTP request header to access protected resources.

How Bearer token works:

  1. The user enters their login and password.
  2. The server verifies the data and issues a token (usually JWT).
  3. The client saves the token and includes it in subsequent requests in the header Authorization: Bearer <token>.
  4. The server verifies the token, and if it is valid, grants access to the resource.

Example header:

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
What is authentication? How does a Bearer token work… - sobes.tech