Skip to main content
API reference

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

Every operation below requires a Bearer token. See Authentication.

GET /oauth/authorize

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"

POST /oauth/authorize

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"

POST /oauth/register

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 response

{
  "client_id": "client_0000000000000000",
  "redirect_uris": [
    "https://example.com/hook"
  ],
  "client_name": "Example",
  "token_endpoint_auth_method": "none",
  "grant_types": [
    "string"
  ],
  "response_types": [
    "string"
  ]
}

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"
       ]
     }'

POST /oauth/token

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 response

{
  "access_token": "string",
  "token_type": "Bearer",
  "expires_in": 0,
  "refresh_token": "string",
  "scope": "string"
}

Example request

curl -X POST https://api.codespar.dev/oauth/token \
  -H "Authorization: Bearer $CODESPAR_API_KEY"
OAuth | CodeSpar