Sobes.tech
Junior

What is Bearer token authentication?

sobes.tech AI

Answer from AI

Bearer token is a standard authentication method in HTTP, used in OAuth 2.0 and other protocols. The client sends the token in the Authorization header with the Bearer prefix.

Authorization: Bearer <token>

The server verifies the token's validity and, if it is valid, grants access to the protected resource. The token usually is a string, such as a JWT (JSON Web Token), containing information about the user and their permissions.

Advantages:

  • Simple to implement.
  • Secure when used with SSL/TLS.
  • Low server load due to statelessness.

Disadvantages:

  • Risk of token theft (data compromise).
  • Need for a mechanism to revoke tokens in case of theft or user logout.

Used in RESTful APIs, Single Page Applications, mobile applications.