The value of an Authorization
header in a request contains a value that can be used by the server to authorize the request.
The header comes in the following format:
Authorization: <auth-scheme> <authorization-parameters>
Where the auth schema tells us what type of value is set as a parameter.
There are several types of schemas defined, here are some examples:
There is a more complete list here.
So bearer is an authentication schema.
Bearer tokens can come in different formats. A JWT is one format of a token, another type of token format is called an opaque token.
A JWT is a base64 encoded Json formatted string, containing a header section, a body section and lastly a signature section. In this type of token you can add different claims
, which are claiming certain things (like the username, email address, what roles etc)
While an opaque token is just a random unique string, that is opaque that doesn't contain any additional information.
JWT tokens and opaque tokens are different bearer token formats.
How they are used, and when to use each, is a huge discussion; there are good and bad usages. But both of these are usually used when implementing oauth2, but there are several other user cases.
I have seen JWTs been sent in bodies to just send signed data. So to be really honest a JWT is just a format of some data. It does not necessarily need be a token.