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:
- The user enters their login and password.
- The server verifies the data and issues a token (usually JWT).
- The client saves the token and includes it in subsequent requests in the header
Authorization: Bearer <token>. - The server verifies the token, and if it is valid, grants access to the resource.
Example header:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...