---
title: "Authorize"
method: POST
path: "/api/oauth/authorize"
tags: ["oauth"]
---

# Authorize

`POST /api/oauth/authorize`

OAuth 2.0 Authorization Endpoint

User must be logged in (authenticated with Supabase JWT).
This endpoint creates an authorization code and returns a redirect URL.

PKCE (Proof Key for Code Exchange) is REQUIRED for all authorization requests.

The frontend consent screen should call this endpoint after the user approves,
then redirect the user to the returned `redirect_url`.

Request Body:
- client_id: The OAuth application's client ID
- redirect_uri: Where to redirect after authorization (must match registered URI)
- scopes: List of permissions (e.g., "EXECUTE_GRAPH READ_GRAPH")
- state: Anti-CSRF token provided by client (will be returned in redirect)
- response_type: Must be "code" (for authorization code flow)
- code_challenge: PKCE code challenge (required)
- code_challenge_method: "S256" (recommended) or "plain"

Returns:
- redirect_url: The URL to redirect the user to (includes authorization code)

Error cases return a redirect_url with error parameters, or raise HTTPException
for critical errors (like invalid redirect_uri).

## Request body

- AuthorizeRequest — OAuth 2.0 authorization request
  - `client_id` string, required — Client identifier
  - `redirect_uri` string, required — Redirect URI
  - `scopes` string[], required — List of scopes
  - `state` string, required — Anti-CSRF token from client
  - `response_type` string — Must be 'code' for authorization code flow
  - `code_challenge` string, required — PKCE code challenge (required)
  - `code_challenge_method` 'S256' | 'plain' — PKCE code challenge method (S256 recommended)

## Response `200`

Successful Response

- AuthorizeResponse — OAuth 2.0 authorization response with redirect URL
  - `redirect_url` string, required — URL to redirect the user to

## Other responses

- `401` — Authentication required
- `422` — Validation Error

---

[API](https://skmtc.net/significant-gravitas/apis/autogpt-agent-server.md) · [All operations](https://skmtc.net/significant-gravitas/apis/autogpt-agent-server/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/significant-gravitas/autogpt-agent-server/versions/382041c7ecb2/schema)
