Web API Authentication Basic vs Bearer

SharmaPattar picture SharmaPattar · Dec 1, 2015 · Viewed 41.6k times · Source

I have created JWT based Authentication in my Web API application. I am not able to figure out the difference between

  1. Basic Token
  2. Bearer Token

Can someone please help me?

Answer

Florent Morselli picture Florent Morselli · Dec 1, 2015

The Basic and Digest authentication schemes are dedicated to the authentication using a username and a secret (see RFC7616 and RFC7617).

The Bearer authentication scheme is dedicated to the authentication using a token and is described by the RFC6750. Even if this scheme comes from an OAuth2 specification, you can still use it in any other context where tokens are exchange between a client and a server.

Concerning the JWT authentication and as it is a token, the best choice is the Bearer authentication scheme. Nevertheless, nothing prevent you from using a custom scheme that could fit on your requirements.