Authentication
Open the Auth tab and choose a type. DotFetch builds the right header or query parameter for you, and a preview shows exactly what will be sent.
| Type | Sends |
|---|---|
| No Auth | Nothing |
| Basic Auth | Authorization: Basic <base64 of user:password> |
| Bearer Token | Authorization: Bearer <token> |
| API Key | Your key name and value, as a header or a query parameter |
| OAuth 2.0 (Client Credentials) | Fetches a token from your token URL, then sends Authorization: Bearer <token> |
Every field accepts {{VARIABLES}}, so secrets can stay in your .env file instead of being typed into the UI. Click 👁️ to show a hidden value and 🙈 to hide it again.
Basic Auth
| Field | Example |
|---|---|
| Username | {{API_USER}} |
| Password | {{API_PASS}} |
# .env
API_USER=testuser
API_PASS=testpassTry it against httpbin, which only returns 200 for the right credentials:
GET https://httpbin.org/basic-auth/testuser/testpass
DotFetch fills in the variables first, then Base64-encodes testuser:testpass, so the header is correct even when the password comes from .env.
Bearer Token
| Field | Example |
|---|---|
| Token | {{ACCESS_TOKEN}} |
GET https://httpbin.org/bearer
→ Authorization: Bearer eyJhbGciOi...Type only the token. DotFetch adds the Bearer prefix.
API Key
| Field | Example |
|---|---|
| Key name | X-API-Key |
| Value | {{API_KEY}} |
| Add to | Header or Query Params |
Header
X-API-Key: sk_test_123
Query Params
https://api.example.com/v1/weather?city=Cairo&api_key=sk_test_123
If the URL or the Params tab already has a parameter with the same name, the Auth tab's value replaces it, so the key is never sent twice:
URL typed: https://api.example.com/v1/data?x=1&api_key=old
Auth tab: api_key = new (Add to Query Params)
Sent: https://api.example.com/v1/data?x=1&api_key=newOAuth 2.0 (Client Credentials)
Use this for machine-to-machine APIs where you have a client ID and secret.
| Field | Example |
|---|---|
| Token URL | https://auth.example.com/oauth/token |
| Client ID | {{CLIENT_ID}} |
| Client Secret | {{CLIENT_SECRET}} |
| Scope (optional) | read:users write:users |
- Fill in the fields and click ⚡ Fetch & Inject Token.
- DotFetch sends
grant_type=client_credentialsto the token URL, putting the client ID and secret in a BasicAuthorizationheader (RFC 6749 §2.3.1). - A card shows the token and when it expires. Every request you send now carries
Authorization: Bearer <token>.
When the token expires, Send is blocked with "OAuth token expired — please fetch a new token". Click ⚡ Fetch & Inject Token again to get a new one.
Which header wins?
The Auth tab always has the last word:
- Your Headers tab rows are applied first.
- Your Pre-Request script runs and may change headers.
- The Auth tab is applied last. It replaces any
Authorizationheader (in any letter case) from steps 1 and 2.
// Pre-Request script, with Auth = Bearer Token
dotfetch.request.headers['Authorization'] = 'Bearer from-script';
// → ignored: the Auth tab's Bearer token is what gets sentWant a script to build the Authorization header itself, for a custom signature scheme? Set Auth to No Auth, and the script's header is sent as-is.
What gets saved
Secrets are never written to disk. When you save a request to a collection, or it's recorded in History, the secret fields are handled like this:
| Field holds | Saved as | Why |
|---|---|---|
{{API_KEY}} | {{API_KEY}} | It's only a variable name; the secret stays in .env |
sk_live_123 | (empty) | A real secret is never stored |
Bearer {{TOKEN}} | (empty) | Any literal text next to the variable could be part of a secret |
This applies to the Basic Password, Bearer Token, API Key Value, and OAuth Client Secret. The fetched OAuth access token is never saved. The username, key name, token URL, client ID, and scope are saved as typed.
Tip: put every secret in .env and type only {{VARIABLE}} in the Auth tab. Saved requests then work as soon as you load them, and no secret ever reaches DotFetch's storage.
cURL export and secrets
📤 Export (cURL) copies the auth values exactly as they appear in the Auth tab:
- If you typed the real secret, the copied command contains it. Treat it like a password and don't paste it into tickets or chat.
- If you used
{{API_KEY}}, the command contains the literal text{{API_KEY}}. curl doesn't know your.env, so replace it before running the command.