Most real APIs need to know who is calling. Hoppscotch’s Authorization tab builds the right headers for you, so you don’t have to encode credentials by hand. This guide covers the common methods and how to test each one safely.
No auth
Public APIs need nothing. Leave the type set to None.
Basic auth
Basic auth sends a username and password with every request, encoded in an Authorization: Basic … header. The encoding is not encryption, so only use it over HTTPS.
To try it, use the public testing service httpbin:
- Send
GET https://httpbin.org/basic-auth/demo/secret123with no auth — you’ll get 401 Unauthorized. - In the Authorization tab choose Basic Auth, enter username
demoand passwordsecret123. - Send again — now it returns 200 with
"authenticated": true.
Bearer token
Most modern APIs hand out a token (often a JWT) after you log in. You then send it as Authorization: Bearer <token>.
- Choose Bearer in the Authorization tab.
- Paste the token — or better, use a variable:
<<token>>.
Test it with GET https://httpbin.org/bearer, which returns 200 when a Bearer token is present and 401 when it isn’t.
Save the token automatically after logging in with one line in the login request’s Tests tab: pw.env.set("token", pw.response.body.token); — see environment variables.
API keys
Some services want a key in a header (for example X-API-Key) or in the URL (for example ?api_key=…). Hoppscotch includes an API key option where you choose the name, value and whether it goes in the header or query string. You can also simply add the header yourself in the Headers tab.
OAuth 2.0
OAuth 2.0 is used when an app acts on behalf of a user — “Sign in with…” buttons are the familiar example. Hoppscotch can run the flow for you and store the resulting access token. You’ll need values from the API provider’s developer console:
- Authorization URL and Token URL
- Client ID (and a Client Secret for confidential apps)
- Scopes — the permissions you’re asking for
- Redirect / callback URL — the provider must have this registered for your client
Choose the grant type the provider supports. Authorization Code is the standard for user logins, and turning on PKCE adds protection that most providers now recommend or require. Client Credentials is for server-to-server access without a user. After you start the flow and approve access in the browser window, Hoppscotch receives the token and uses it in the request.
If the flow fails, the most common causes are a redirect URL that doesn’t exactly match the one registered with the provider, a missing scope, or using the wrong grant type for the client you created.
Inherit auth from a collection
Set the authorization once on a collection or folder, then choose Inherit on each request inside it. One token update fixes every request. This is explained further in collections and folders.
Keep credentials out of shared files
- Store passwords, secrets and tokens in environment variables, not directly in requests.
- Mark sensitive variables as secret where your version supports it.
- Before exporting a collection, check the Authorization tabs for real credentials.