Documentation Index
Fetch the complete documentation index at: https://docs.natecosmic.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
COSMIC supports OAuth 2.1 Authorization Code with PKCE. Most integrations follow this flow:Before you begin
Create an app in the developer portal. You will need your app’sclient_id, at least one allowed redirect_uri, and the scopes your app will use.
See Creating apps.
Authorization endpoint
Start the OAuth flow by redirecting the user to:&scope=openid%20email%20profile if you need broader sign-in profile data or an ID token—see scope below.
Query parameters
Your app’s client identifier from the developer portal.
The callback URI to redirect the user to after authorization. This must
exactly match one of the allowed redirect URIs configured for your app.
Redirect URIs must match exactly, including scheme, host, path, and trailing
slash. See Redirect URIs.
Optional. Space-separated OpenID Connect / OAuth sign-in values for this step only (for example
openid email profile). They do not select COSMIC API permissions—those come from your app in the
developer portal; see Scopes. If you omit scope, COSMIC uses a default suitable for basic sign-in; include openid when you need an ID token in the token response.Must be
code.The Base64URL-encoded SHA-256 hash of your app’s
code_verifier.Must be
S256.A client-generated value used to prevent
CSRF.
Generate a unique value per request and verify it on callback.
User consent and redirect
After the user signs in and approves the request, COSMIC redirects the browser to your registeredredirect_uri.
Example:
- verify that
statematches the value you originally sent - extract the authorization
code - exchange that code at the token endpoint
Token endpoint
Exchange the authorization code at:Authorization code exchange parameters
Must be
authorization_code.The authorization code returned to your
redirect_uri.The same
redirect_uri used in the authorization request.Your app’s client identifier.
The original random secret generated by your app for this authorization
request.
- Public client
- Confidential client
Send the token request without a
client_secret.Token response
A successful response returns OAuth tokens, including an access token and, when applicable, a refresh token.The access token used to call COSMIC APIs.
The token type. Typically
Bearer.The lifetime of the access token in seconds.
A refresh token that can be used to obtain a new access token, when
applicable.
Space-delimited sign-in / identity scopes for this authorization (from your authorize request, or COSMIC defaults). This is separate from COSMIC API scopes on the token; see Scopes and Access tokens.
After you receive a token
Use the access token as a Bearer credential on API requests. See Access tokens forGET /v1/me, scopes on the token, and how to list organizations and members.
If a call returns 403, common causes include:
- the token does not include the scope required for that endpoint
- the app cannot access that organization or member in the current context
- an organization admin must re-approve the app in COSMIC after you add or widen scopes in the developer portal
Refresh tokens
To obtain a new access token, send a refresh token to the same token endpoint:Refresh token parameters
Must be
refresh_token.The refresh token previously issued to your app.
Your app’s client identifier, if required by your app’s configured token
endpoint authentication method.
- Public client
- Confidential client
Send the refresh token request without a
client_secret.Common errors
redirect_uri mismatch
The redirect_uri sent in the authorization request and token request must exactly match a URI registered for the client.
This includes:
- scheme
- host
- path
- trailing slash
invalid_grant
Common causes include:
- the authorization code expired
- the authorization code was already used
- the
code_verifierdoes not match the original PKCE challenge - the
redirect_uridoes not match the original authorization request
state mismatch
If you send state, verify it on callback. Reject the response if the returned value does not match the original value stored by your app.

