Skip to content

Commit 8aaa0b3

Browse files
committed
docs: add authentication user guide
1 parent a12254b commit 8aaa0b3

11 files changed

+337
-0
lines changed

doc/user_guide/authentication.md

Lines changed: 337 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,337 @@
1+
# Authentication in API Dash
2+
3+
This guide explains how to authenticate your API requests in API Dash. We’ll start from zero and walk through each supported method with plain-language steps, examples, and tips.
4+
5+
Use this page when you need your requests to include credentials (tokens, keys, usernames/passwords, etc.).
6+
7+
8+
> ![Authentication tab overview — Request screen with Authentication tab highlighted and Auth Type dropdown visible](images/auth/auth-tab-overview.png)
9+
10+
---
11+
12+
## Where to find authentication
13+
14+
1. Open any request (or create a new one).
15+
2. Switch to the “Authentication” tab.
16+
3. Use the “Authentication Type” dropdown to select how you want to authenticate.
17+
18+
> ![Auth Type dropdown showing options (None, API Key, Bearer, Basic, Digest, JWT, OAuth 1.0, OAuth 2.0)](images/auth/auth-type-dropdown.png)
19+
20+
When a type is selected, API Dash shows the relevant fields. As you type, your request preview updates and API Dash will attach the credentials to the outgoing request either in headers or in the URL (depending on the method).
21+
22+
---
23+
24+
## Supported methods at a glance
25+
26+
- None (No Auth)
27+
- API Key
28+
- Bearer Token
29+
- Basic Auth (username & password)
30+
- Digest Auth
31+
- JWT Bearer (signed JSON Web Token)
32+
- OAuth 1.0
33+
- OAuth 2.0 (Authorization Code, Resource Owner Password, Client Credentials; PKCE support)
34+
35+
Each section below explains what it is, when to use it, and exactly how to fill it in API Dash.
36+
37+
---
38+
39+
## None (No Auth)
40+
41+
- Use when your API is public or doesn’t require credentials.
42+
- API Dash won’t add any Authorization headers or query parameters.
43+
44+
Steps:
45+
1. In Authentication Type, select “None”.
46+
2. Send your request as usual.
47+
48+
---
49+
50+
## API Key
51+
52+
API key auth sends a single key-value pair with your request, either in a header or as a query parameter.
53+
54+
Typical use: Public APIs that issue static keys for access control.
55+
56+
What API Dash sends:
57+
- If “Add to” is Header: a header named <Name> with the key as its value (default name: `x-api-key`).
58+
- If “Add to” is Query Params: a `?<Name>=<Key>` appended to the URL.
59+
60+
Fields in API Dash:
61+
- Add to: Header or Query Params
62+
- Header/Query Param Name: default `x-api-key` (editable)
63+
- API Key: your actual key value
64+
65+
Steps:
66+
1. Select “API Key”.
67+
2. Choose “Add to”: Header (default) or Query Params.
68+
3. Set the “Header/Query Param Name” (leave as `x-api-key` unless your API expects a different name).
69+
4. Paste your API key in “API Key”.
70+
5. Send the request.
71+
72+
> ![API Key fields — Add to, Header/Query Param Name, and API Key](images/auth/api-key-fields.png)
73+
74+
Example result (Header mode):
75+
- Header: `x-api-key: <your-key>`
76+
77+
---
78+
79+
## Bearer Token
80+
81+
Bearer tokens are access tokens like OAuth 2.0 access tokens or other opaque tokens your API provides.
82+
83+
What API Dash sends:
84+
- Header: `Authorization: Bearer <token>`
85+
86+
Fields in API Dash:
87+
- Token
88+
89+
Steps:
90+
1. Select “Bearer Token”.
91+
2. Paste your token into “Token”.
92+
3. Send the request.
93+
94+
> ![Bearer Token field — single Token input](images/auth/bearer-fields.png)
95+
96+
---
97+
98+
## Basic Auth
99+
100+
Basic authentication encodes a username and password and sends them in the Authorization header.
101+
102+
What API Dash sends:
103+
- Header: `Authorization: Basic <base64(username:password)>`
104+
105+
Fields in API Dash:
106+
- Username
107+
- Password
108+
109+
Steps:
110+
1. Select “Basic Auth”.
111+
2. Enter your Username and Password.
112+
3. Send the request.
113+
114+
> ![Basic Auth fields — Username and Password](images/auth/basic-fields.png)
115+
116+
Security note: Basic Auth is only safe over HTTPS. Avoid using it over plain HTTP.
117+
118+
---
119+
120+
## Digest Auth
121+
122+
Digest authentication is a challenge-response mechanism. The server provides a challenge (realm, nonce, etc.), and the client computes a response using a hash function.
123+
124+
When to use: If the API server requires Digest Auth (you’ll typically see a 401 with `WWW-Authenticate: Digest ...`).
125+
126+
What API Dash sends:
127+
- An `Authorization: Digest ...` header built using the fields below.
128+
129+
Fields in API Dash:
130+
- Username: your account username
131+
- Password: your account password (hashed in the auth process, not sent in plain text)
132+
- Realm: protection space defined by the server (from server challenge)
133+
- Nonce: server-provided random value
134+
- Algorithm: hashing algorithm (e.g., MD5, SHA-256, SHA-512 depending on server)
135+
- QOP: quality of protection (commonly `auth` or `auth-int`)
136+
- Opaque: server-provided string to echo back
137+
138+
Steps:
139+
1. Select “Digest”.
140+
2. Fill Username and Password.
141+
3. Fill the challenge details (Realm, Nonce, Opaque) from the server’s 401 response(done automatically by APIDash).
142+
4. Choose the Algorithm and QOP your server requires.
143+
5. Send the request again.
144+
145+
> ![Digest Auth fields — Username, Password, Realm, Nonce, Algorithm, QOP, Opaque](images/auth/digest-fields.png)
146+
147+
Tip: If you don’t have Realm/Nonce/Opaque yet, send the request without them, APIDash will fill them for you.
148+
149+
---
150+
151+
## JWT Bearer (signed JSON Web Token)
152+
153+
JWT lets you create and sign a token that your API accepts as a credential. API Dash can sign a JWT for you based on your inputs.
154+
155+
What API Dash sends:
156+
- If “Add JWT token to” is Header: `Authorization: Bearer <signed-jwt>`
157+
- If “Add JWT token to” is Query Params: `?token=<signed-jwt>`
158+
159+
Fields in API Dash:
160+
- Add JWT token to: Header or Query Params
161+
- Algorithm: select the signing algorithm
162+
- HS...: HMAC with SHA (requires a Secret)
163+
- RS...: RSA (requires a Private Key)
164+
- ES...: ECDSA (requires a Private Key)
165+
- PS...: RSA-PSS (requires a Private Key)
166+
- Secret: the HMAC secret (for HS algorithms)
167+
- Secret is Base64 encoded: check if your secret is base64
168+
- Private Key: PKCS#8 PEM for RS/ES/PS algorithms
169+
- Payload: JSON payload to include in the token (e.g., `{"sub":"123","name":"Alice"}`)
170+
171+
Steps (HS256 example):
172+
1. Select “JWT”.
173+
2. Set “Add JWT token to” -> Header (recommended).
174+
3. Choose Algorithm: HS256.
175+
4. Enter your Secret (check “Secret is Base64 encoded” only if your secret is actually base64 encoded).
176+
5. Enter your JSON Payload.
177+
6. Send the request. API Dash signs and attaches the token.
178+
179+
Steps (RS256 example):
180+
1. Select “JWT” Bearer.
181+
2. Set “Add JWT token to” -> Header.
182+
3. Choose Algorithm: RS256.
183+
4. Paste your PKCS#8 Private Key into “Private Key”.
184+
5. Enter your JSON Payload.
185+
6. Send the request.
186+
187+
> ![JWT fields — Add to, Algorithm, Secret or Private Key, and Payload](images/auth/jwt-fields.png)
188+
189+
Notes:
190+
- Header prefix is `Bearer` when adding to headers.
191+
- Query parameter key is `token` when adding to URL.
192+
- Ensure clocks are in sync if your API validates `iat`, `nbf`, or `exp` claims.
193+
194+
---
195+
196+
## OAuth 1.0
197+
198+
OAuth 1.0 signs requests using consumer credentials and (optionally) user access tokens. API Dash generates the OAuth 1.0 signature based on the fields you enter.
199+
200+
What API Dash sends:
201+
- The OAuth 1.0 parameters and signature, attached according to your configuration.
202+
203+
Fields in API Dash:
204+
- Consumer Key
205+
- Consumer Secret
206+
- Signature Method: HMAC or PLAINTEXT variants (choose what your API requires)
207+
- Access Token (optional; required for 3-legged flows after authorization)
208+
- Token Secret (optional; pairs with Access Token for signing)
209+
- Callback URL (if your provider requires a callback during authorization)
210+
- Verifier (PIN/code returned by provider after user authorization)
211+
- Timestamp (usually auto-generated by servers/clients; enter only if required)
212+
- Nonce (random string; enter only if required by your flow)
213+
- Realm (optional)
214+
215+
Steps (high level):
216+
1. Select “OAuth 1.0”.
217+
2. Enter Consumer Key and Consumer Secret.
218+
3. Choose your Signature Method (check your API docs).
219+
4. If your API uses 2‑legged OAuth 1.0, you typically won’t have Access Token/Token Secret.
220+
5. If your API requires an access token (e.g., from a completed 3‑legged flow), paste the Access Token and Token Secret you obtained (and Verifier if your provider requires it).
221+
6. Send your request.
222+
223+
Note: API Dash does not perform the 3‑legged OAuth 1.0 authorization flow. Obtain tokens externally and enter them here. See “Limitations (OAuth 1.0)” below.
224+
225+
Credential storage:
226+
- API Dash stores OAuth 1.0 tokens/credentials in your workspace at `oauth1_credentials.json` when applicable.
227+
228+
> ![OAuth 1.0 fields — Consumer Key/Secret, Signature Method, tokens and advanced fields](images/auth/oauth1-fields.png)
229+
230+
Tip: Some providers require parameters to be in the URL/body vs. header. API Dash handles parameter placement while signing; ensure your request method/body type matches provider expectations.
231+
232+
### Limitations (OAuth 1.0)
233+
234+
- API Dash doesn’t implement the complete three-legged OAuth 1.0 flow (request token → user authorization → access token). Obtain the Access Token and Token Secret (e.g., from provider portal, from your backend, or from another request) and enter them here.
235+
236+
---
237+
238+
## OAuth 2.0
239+
240+
OAuth 2.0 issues short-lived access tokens and (optionally) long-lived refresh tokens. API Dash supports common grant types and PKCE.
241+
242+
Default behavior:
243+
- API Dash sends `Authorization: Bearer <access_token>` on requests that use OAuth 2.0.
244+
- Tokens can be read from and written to a credentials file in your workspace, and the UI shows token details if present.
245+
246+
Grant types supported:
247+
- Authorization Code (with optional PKCE)
248+
- Resource Owner Password (username/password)
249+
- Client Credentials
250+
251+
Fields in API Dash:
252+
- Grant Type: choose one of the above
253+
- Authorization URL (Authorization Code)
254+
- Access Token URL (all grant types)
255+
- Client ID (all grant types)
256+
- Client Secret (all grant types, except public clients where it’s not used)
257+
- Redirect URL (Authorization Code)
258+
- Scope (space-separated)
259+
- State (Authorization Code)
260+
- Code Challenge Method (Authorization Code with PKCE): SHA-256 or Plaintext
261+
- Username, Password (Resource Owner Password)
262+
- Refresh Token (optional; displayed/stored if provided by server)
263+
- Identity Token (optional; OpenID Connect providers may return this)
264+
- Access Token (current token value, if any)
265+
266+
Token persistence and session control:
267+
- API Dash uses a credentials file at `oauth2_credentials.json` in your workspace to store tokens returned by the provider.
268+
- If the file includes an expiration timestamp, the UI shows “Token expires in …”.
269+
- Use “Clear OAuth2 Session” to delete the credentials file and reset tokens in the UI.
270+
271+
> ![OAuth 2.0 fields — Grant Type, URLs, Client ID/Secret, Scope, and token fields](images/auth/oauth2-fields.png)
272+
> ![OAuth 2.0 token expiration status — Access Token with “Token expires in …” message](images/auth/oauth2-expiration.png)
273+
274+
### Platform-specific behavior
275+
276+
- Desktop (macOS, Windows, Linux)
277+
- Default Redirect URL: `http://localhost:{port}/callback`
278+
- Port range used by the local callback server: 8080–8090 (first available port)
279+
- Opens your system browser for authorization and handles the callback locally
280+
- Mobile (iOS, Android)
281+
- Default Redirect URL: `apidash://oauth2`
282+
- Uses a custom URL scheme; authorization occurs in-app or via system browser
283+
284+
### Limitations (OAuth 2.0)
285+
286+
- Token endpoint responses must be JSON (`application/json`). API Dash sets `Accept: application/json` on token requests; providers returning `application/x-www-form-urlencoded` or `text/plain` are not supported.
287+
- On desktop, the local callback requires a free port between 8080 and 8090. If all are occupied, the flow fails.
288+
- Not supported grant types: Implicit and Device Authorization.
289+
290+
For technical details, see the developer guide: [OAuth Authentication Limitations](../dev_guide/oauth_authentication_limitations.md).
291+
292+
Using Authorization Code (with or without PKCE):
293+
1. Select “OAuth 2.0”.
294+
2. Set Grant Type: Authorization Code.
295+
3. Fill Authorization URL, Access Token URL, Client ID, Client Secret (if required), Redirect URL, Scope, and State.
296+
4. If using PKCE, choose the Code Challenge Method (SHA-256 recommended). API Dash will handle code challenge/verifier details during the flow.
297+
5. Complete your provider’s auth steps (you may need to perform the code exchange by calling the token endpoint from a request in API Dash using these values). When the provider returns tokens, API Dash will store them in `oauth2_credentials.json` and show them in the UI.
298+
6. Subsequent requests will include your Access Token automatically.
299+
300+
Using Resource Owner Password:
301+
1. Select Grant Type: Resource Owner Password.
302+
2. Fill Access Token URL, Client ID/Secret (if required), Scope, Username, and Password.
303+
3. Obtain tokens from the provider (by calling the token endpoint with these values). API Dash will reflect the tokens if saved to the credentials file.
304+
305+
Using Client Credentials:
306+
1. Select Grant Type: Client Credentials.
307+
2. Fill Access Token URL, Client ID/Secret, and Scope (if required).
308+
3. Obtain and store the Access Token. Requests will include the token automatically.
309+
310+
Refreshing tokens:
311+
- If your provider returns a Refresh Token, API Dash will auto-refresh access tokens in the background when needed and update `oauth2_credentials.json`.
312+
- You can also paste new token values directly into the fields when testing or overriding.
313+
314+
---
315+
316+
## Troubleshooting & tips
317+
318+
- Getting 401/403? Double-check the auth type and field values. Verify the header/query params match what your API expects.
319+
- Wrong token location? For API Key and JWT, confirm “Add to” is set correctly.
320+
- OAuth redirect issues? Make sure the Redirect URL in API Dash exactly matches what you registered with the provider.
321+
- Token not appearing? For OAuth 2.0/1.0, check that your credentials file exists in the workspace and contains the expected fields.
322+
- Security: Use HTTPS. Keep secrets and private keys safe. Avoid committing credentials to git.
323+
- Desktop OAuth 2.0: ensure at least one port in 8080–8090 is free; stop conflicting services before starting the flow.
324+
- Non-JSON token responses: if your provider’s token endpoint doesn’t return JSON, the flow isn’t supported. Consider a proxy that converts responses to JSON or contact the provider.
325+
326+
---
327+
328+
## FAQ
329+
330+
- Can I use custom header names for Bearer tokens?
331+
- If you need a custom header, use API Key auth with the header name `Authorization` and value like `Bearer <token>`.
332+
- Can I add custom JWT headers or change the header prefix?
333+
- API Dash uses the `Bearer` prefix for header-based JWTs and the `token` key for query params.
334+
- Do I have to use the credentials files?
335+
- For OAuth 1.0/2.0, the credentials files help API Dash remember tokens. You can also paste tokens manually.
336+
337+
You’re set! Pick the auth type, fill the fields, and send your request.
297 KB
Loading
230 KB
Loading
252 KB
Loading
288 KB
Loading
278 KB
Loading
327 KB
Loading
339 KB
Loading
351 KB
Loading
492 KB
Loading

0 commit comments

Comments
 (0)