Menu
Coddy logo textTech

API Keys and Bearer

Lesson 43 of 47 in Coddy's Networking with the Terminal course.

Most APIs identify you with a header rather than a login form. The common shape is:

curl -s -H 'Authorization: Bearer YOUR_TOKEN' http://127.0.0.1:9132/me

Bearer means exactly what it sounds like: whoever bears this token is treated as you. There is no further check, no password, no second factor. A leaked token is a leaked account until it is revoked.

That has consequences for how you handle it. A token in a URL ends up in browser history and server logs, so it belongs in a header. A token in a shell command ends up in your shell history, which is why real scripts read it from an environment variable instead of hard-coding it.

Some APIs use a differently named header such as X-API-Key. The mechanics are identical: a secret string in a header, sent with every request.

challenge icon

Challenge

Hard

Send a token and confirm it arrived intact.

  1. Start the capture listener on port 9132
  2. Request /me carrying the header Authorization: Bearer t0ken
  3. Print the authorization line from req.txt

Expected output:

Authorization: Bearer t0ken

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Networking with the Terminal

Practice on your own: Terminal playground