Skip to content

Authentication ​

The S-Launch API supports two authentication methods:

  1. OAuth2 Password Bearer β€” username/password exchange that yields a short-lived access token and a refresh cookie. Best for interactive sessions and first-party clients.
  2. API Key Header β€” a long-lived X-API-Key header value. Best for server-to-server and automation use cases.

Most endpoints accept either method (the OpenAPI security block lists both). The notable exceptions are the OAuth2 endpoints themselves and the bootstrap activation endpoint, which are unauthenticated.

OAuth2 β€” Password Flow ​

Endpoint ​

POST /api/login/access-token

Exchanges a username and password for an access token. Request body is form-urlencoded, not JSON.

Request body β€” Body_Authentication-Login

FieldTypeRequiredNotes
usernamestringyesUser's login.
passwordstringyesUser's password.
grant_typestringnoIf supplied, must be password.
scopestringnoSpace-separated scopes to request (default: empty).
client_idstringnoReserved for future use.
client_secretstringnoReserved for future use.

Response 200 β€” LoginResponse

json
{
  "access_token": "eyJhbGciOi…",
  "token_type": "bearer"
}

The server also sets a slaunch_refresh_cookie HTTP-only cookie that is used by Refresh Access Token.

Errors: 401 (bad credentials), 422 (malformed request) β€” see Conventions β€Ί Errors.

curl ​

bash
curl -X POST "https://<tenant>.s-launch.com/api/login/access-token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -c cookies.txt \
  --data-urlencode "username=alice@example.com" \
  --data-urlencode "password=hunter2"

The -c cookies.txt flag captures the refresh cookie for later use.

JavaScript (fetch) ​

js
const body = new URLSearchParams({
  username: 'alice@example.com',
  password: 'hunter2',
})

const res = await fetch('https://<tenant>.s-launch.com/api/login/access-token', {
  method: 'POST',
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  credentials: 'include', // accept the refresh cookie
  body,
})

const { access_token } = await res.json()

credentials: 'include' is required for the refresh cookie to be stored by the browser.

Using the Access Token ​

Send the access token on every subsequent request as a Bearer token:

bash
curl "https://<tenant>.s-launch.com/api/self" \
  -H "Authorization: Bearer eyJhbGciOi…"
js
await fetch('https://<tenant>.s-launch.com/api/self', {
  headers: { Authorization: `Bearer ${access_token}` },
})

Refresh Access Token ​

Endpoint ​

POST /api/login/refresh-token

Issues a new access token using the slaunch_refresh_cookie set during login. There is no request body β€” the refresh credential travels in a cookie.

Cookie

NameRequiredNotes
slaunch_refresh_cookieyesSet by POST /api/login/access-token.

Response 200 β€” LoginResponse (same shape as login).

Errors: 401 (cookie missing or revoked), 422.

curl ​

bash
curl -X POST "https://<tenant>.s-launch.com/api/login/refresh-token" \
  -b cookies.txt -c cookies.txt

JavaScript (fetch) ​

js
const res = await fetch('https://<tenant>.s-launch.com/api/login/refresh-token', {
  method: 'POST',
  credentials: 'include',
})

const { access_token } = await res.json()

The browser automatically attaches the refresh cookie when credentials: 'include' is set; the server may rotate the cookie on success.

Logout ​

Endpoint ​

GET /api/logout

Invalidates the current session and clears the refresh cookie.

Required scope: none beyond a valid session (any authenticated user can log out).

Response 200 β€” empty body.

curl ​

bash
curl "https://<tenant>.s-launch.com/api/logout" \
  -H "Authorization: Bearer eyJhbGciOi…" \
  -b cookies.txt -c cookies.txt

JavaScript (fetch) ​

js
await fetch('https://<tenant>.s-launch.com/api/logout', {
  headers: { Authorization: `Bearer ${access_token}` },
  credentials: 'include',
})

Google OAuth ​

A two-step flow for "Sign in with Google":

Start ​

GET /api/login/google/start

Returns the Google authorization URL the user should be redirected to. The browser-side client typically just navigates to the returned URL.

Exchange ​

GET /api/login/google/exchange?assertion=<jwt>

Verifies the JWT assertion returned by Google and creates a session β€” same response shape and refresh-cookie behavior as the password flow.

Query parameters

NameTypeRequiredDescription
assertionstringyesThe JWT assertion returned by Google's IdP.

Response 200 β€” { access_token, token_type } plus a slaunch_refresh_cookie cookie.

Errors: 401 (invalid assertion), 422.

Browser snippet ​

js
// 1. Kick off the flow.
const { url } = await fetch('https://<tenant>.s-launch.com/api/login/google/start')
  .then(r => r.json())
window.location.href = url

// 2. After Google redirects back with an assertion in the URL, exchange it:
const params = new URLSearchParams(window.location.search)
const res = await fetch(
  `https://<tenant>.s-launch.com/api/login/google/exchange?assertion=${params.get('assertion')}`,
  { credentials: 'include' },
)
const { access_token } = await res.json()

API Key ​

API keys are the simplest authentication mechanism β€” set a single header on each request:

bash
curl "https://<tenant>.s-launch.com/api/store/asset/" \
  -H "X-API-Key: sla_live_…"

Keys are minted and scoped via the API Keys admin endpoints. Each key carries an explicit scope set; requests fail with 403 when a key lacks the scopes a given endpoint requires.

Token Lifetime & Rotation ​

  • Access tokens are short-lived (default lifetime is configured server-side via Configuration).
  • The refresh cookie is HTTP-only and tied to a session; sessions can be inspected and revoked via Sessions (admin) or your own session list at GET /api/self/sessions.
  • Refreshing rotates the access token. Refresh tokens may also rotate; always trust the latest Set-Cookie from /api/login/refresh-token.

See also ​

  • Scopes β€” the authorization model
  • Self β€” the current-user endpoints
  • API Keys β€” minting service credentials
  • Sessions β€” admin session management

S-Launch