

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 10
click for more info
Not enough gems
Cost: 6 gems
1: Authentication With Passwords
incomplete
2: Password Review
incomplete
3: Types of Authentication
incomplete
4: JWTs
incomplete
5: Bearer Tokens
incomplete
6: Authentication With JWTs
incomplete
7: JWT Review
incomplete
8: Revoking JWTs
incomplete
9: Refresh Tokens
incomplete
10: Refresh and Revoke
incomplete
11: Cookies
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Clients send authentication tokens to our API in the Authorization HTTP header:
Authorization: Bearer TOKEN_STRING
The word Bearer describes how the token is used: whoever has the token can use it to authenticate. In Chirpy, that token will be a JWT.
Before we can validate a JWT, we need to extract it from the header's value. We'll write a helper that accepts the full header string, strips off the Bearer prefix, and returns the token.
function extractBearerToken(authorization: string | undefined): string;
It should:
"Bearer TOKEN_STRING", removing the prefix and surrounding whitespace.BadRequestError if the scheme isn't Bearer or the token is empty.Run and submit the CLI tests.