Skip to main content

OAuth

Generated HTTP reference for the 4 operations the published OpenAPI document describes under oauth.

2 min read
View MarkdownEdit on GitHub

OAuth

This page is generated from the published OpenAPI document. It is complete with respect to that document and says nothing about surfaces the document does not describe yet. See what is generated here for what that means.

Base URL: https://api.codespar.dev

None of the operations below takes a credential: the published document declares them open. See Authentication for the rest of the API.

GET /oauth/authorize

GEThttps://api.codespar.dev/oauth/authorize
No credential

Consent page (RFC 6749 §4.1.1 authorization request)

Query parameters

NameTypeRequiredDescription
client_idstringyes
code_challengestringyes
code_challenge_method"S256"yes
redirect_uristringyes
response_type"code"yes
scopestringnoSpace-separated. Requesting more than the pasted key holds is refused.
statestringno

Responses

StatusBodyDescription
200The consent page.
400Rendered as HTML, never redirected.
Example request
curl -X GET https://api.codespar.dev/oauth/authorize \
  -H "Authorization: Bearer $CODESPAR_API_KEY"
const res = await fetch("https://api.codespar.dev/oauth/authorize", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.CODESPAR_API_KEY}`,
  },
});

const data = await res.json();

POST /oauth/authorize

POSThttps://api.codespar.dev/oauth/authorize
No credential

Consent submit — exchanges a pasted API key for an authorization code

Responses

StatusBodyDescription
302Location: <redirect_uri>?code=…&state=… (RFC 6749 §4.1.2).
400Rendered as HTML, never redirected.
Example request
curl -X POST https://api.codespar.dev/oauth/authorize \
  -H "Authorization: Bearer $CODESPAR_API_KEY"
const res = await fetch("https://api.codespar.dev/oauth/authorize", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CODESPAR_API_KEY}`,
  },
});

const data = await res.json();

POST /oauth/register

POSThttps://api.codespar.dev/oauth/register
No credential

Register a client (RFC 7591 dynamic client registration)

Request body

FieldTypeRequiredDescription
client_namestringnoTruncated to 256 characters. Rendered on the consent page.
grant_typesarray of stringno
redirect_urisarray of stringyesAbsolute https URIs; http only for loopback hosts.
response_typesarray of stringno
token_endpoint_auth_methodstringno

Responses

StatusBodyDescription
201objectCreated
400objectinvalid_redirect_uri when a URI is missing, relative, or http on a non-loopback host.

Response 201

FieldTypeRequiredDescription
client_idstringyes
client_namestringno
grant_typesarray of stringyes
redirect_urisarray of stringyes
response_typesarray of stringyes
token_endpoint_auth_method"none"yes
Example request
curl -X POST https://api.codespar.dev/oauth/register \
  -H "Authorization: Bearer $CODESPAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "redirect_uris": [
         "https://example.com/hook"
       ],
       "client_name": "Example",
       "token_endpoint_auth_method": "https://example.com/hook",
       "grant_types": [
         "string"
       ],
       "response_types": [
         "string"
       ]
     }'
const res = await fetch("https://api.codespar.dev/oauth/register", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CODESPAR_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "redirect_uris": [
      "https://example.com/hook"
    ],
    "client_name": "Example",
    "token_endpoint_auth_method": "https://example.com/hook",
    "grant_types": [
      "string"
    ],
    "response_types": [
      "string"
    ]
  }),
});

const data = await res.json();
Example response 201
application/json
{
  "client_id": "client_0000000000000000",
  "redirect_uris": [
    "https://example.com/hook"
  ],
  "client_name": "Example",
  "token_endpoint_auth_method": "none",
  "grant_types": [
    "string"
  ],
  "response_types": [
    "string"
  ]
}

POST /oauth/token

POSThttps://api.codespar.dev/oauth/token
No credential

Token endpoint — authorization_code and refresh_token grants

Responses

StatusBodyDescription
200objectOK
400objectinvalid_grant (code invalid, expired, already used, bound to a different client or redirect_uri, PKCE verification failed, or carrying no recorded scope grant), invalid_request, or unsupported_grant_type.

Response 200

FieldTypeRequiredDescription
access_tokenstringyes
expires_inintegeryes
refresh_tokenstringyes
scopestringyes
token_type"Bearer"yes
Example request
curl -X POST https://api.codespar.dev/oauth/token \
  -H "Authorization: Bearer $CODESPAR_API_KEY"
const res = await fetch("https://api.codespar.dev/oauth/token", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CODESPAR_API_KEY}`,
  },
});

const data = await res.json();
Example response 200
application/json
{
  "access_token": "string",
  "token_type": "Bearer",
  "expires_in": 0,
  "refresh_token": "string",
  "scope": "string"
}
OAuth | CodeSpar