Documentation Index
Fetch the complete documentation index at: https://docs.busha.io/llms.txt
Use this file to discover all available pages before exploring further.
This walkthrough assumes you have already registered your OAuth2 app and have your
client_id and client_secret. Pick one environment — sandbox or production — and use it throughout.Step 1 — Generate PKCE and CSRF values
Your backend generates a fresh PKCE verifier and CSRF state for every authorization request. Never reuse them.CODE_VERIFIER and STATE in the user’s server-side session — you’ll need them in steps 3 and 4.
Step 2 — Redirect the user to Busha
Build the authorization URL and redirect the user’s browser to it. This is the only step that touches the browser.| Parameter | Required | Value |
|---|---|---|
response_type | ✓ | code |
client_id | ✓ | Your app’s client ID |
redirect_uri | ✓ | Byte-identical to a registered URI |
scope | ✓ | Space-separated list of scopes |
state | ✓ | CSRF guard — bind to the user’s session |
code_challenge | ✓ | base64url(sha256(code_verifier)) |
code_challenge_method | ✓ | S256 — plain is not accepted |
Step 3 — Handle the callback
Busha redirects the user to:code:
- Verify
statematches the value you stored in step 1. If it doesn’t match, reject the request — this is a CSRF attack. - Deduplicate the
codeif your callback could fire twice (e.g. the user double-clicks). Codes are single-use; a second exchange attempt returnsinvalid_grant.
?error=access_denied&state=... instead. Render a “continue without connecting” path.
Step 4 — Exchange the code for tokens
This call is server-to-server only. Never expose yourclient_secret or the token response to the browser.
| Token | Returned when |
|---|---|
access_token | Always |
refresh_token | offline_access scope was granted |
id_token | openid scope was granted |
access_token and refresh_token securely. See Token handling for storage requirements and rotation.
Step 5 — Call the Busha API
Attach the access token as a Bearer header:Step 6 — Keep the session alive with refresh
Access tokens expire in ~1 hour. Beforeexp, swap the refresh token for a new pair:
What’s next
Scopes reference
Choose the right scopes for your integration and understand what each one does.
Token handling
Validation, storage, rotation, and revocation in depth.
Endpoints
Full reference for all OAuth2 protocol endpoints.
Errors
Every error code, what causes it, and how to fix it.