
HTTPie: How to Use a Bearer Token
Updated
Learn how to send a bearer token with HTTPie in the terminal

Before we start, make sure you have HTTPie installed on your computer and the token for your API ready. If you don't have HTTPie yet, you can install it with Homebrew:
brew install httpie
First, open your terminal. To send a bearer token, run this command:
http -A bearer -a YOUR_TOKEN https://example.com/me
Just replace YOUR_TOKEN with your actual token and https://example.com/me with your API's URL. The -A bearer flag sets the auth type, and -a is the token itself. HTTPie turns it into an Authorization: Bearer YOUR_TOKEN header. Without a token, most APIs answer with 401 Unauthorized.
Write the Header Yourself
Bearer auth has been built into HTTPie since version 3.0. On an older version, set the header by hand. Keep the quotes, because there's a space after Bearer:
http https://example.com/me 'Authorization:Bearer YOUR_TOKEN'
Save the Token in a Session
To avoid typing the token on every request, add --session=my-api the first time:
http --session=my-api -A bearer -a YOUR_TOKEN https://example.com/me
http --session=my-api https://example.com/me
Sessions are saved per host, so my-api only sends the token to the same host you used it with.
