---
title: "Exchange an OAuth grant"
method: POST
path: "/api/oauth/token"
tags: ["OAuth"]
---

# Exchange an OAuth grant

`POST /api/oauth/token`

## Request

- Base URL: `https://git.cafe`
- URL: `https://git.cafe/api/oauth/token`
- Auth: none required

Exchanges an authorization code with PKCE, or rotates a refresh token, for a bearer token bound to the requested API or MCP resource.

## Request body `application/x-www-form-urlencoded`

- union
  - object
    - `grant_type` 'authorization_code', required
    - `code` string, required
    - `client_id` string, required
    - `redirect_uri` string, required
    - `code_verifier` string, required
    - `resource` string
    - `installation_id` string
  - object
    - `grant_type` 'refresh_token', required
    - `refresh_token` string, required
    - `client_id` string, required
    - `resource` string
    - `installation_id` string
  - object
    - `grant_type` 'urn:ietf:params:oauth:grant-type:jwt-bearer', required
    - `assertion` string, required
    - `resource` string
  - object
    - `grant_type` 'urn:workos:agent-auth:grant-type:claim', required
    - `claim_token` string, required
    - `resource` string

## Response `200`

Response for status 200

- union
  - object
    - `access_token` string, required
    - `token_type` 'Bearer', required
    - `expires_in` integer, required
    - `refresh_token` string, required
    - `scope` string, required
    - `resource` string, uri, required
    - `installation_id` string
    - `id_token` string
  - object
    - `access_token` string, required
    - `token_type` 'Bearer', required
    - `expires_in` integer, required
    - `scope` string, required
    - `resource` string, uri, required
    - `identity_assertion` string
    - `assertion_expires` string, date-time

## Other responses

- `400`: Response for status 400
- `429`: A rate limit is exhausted. Wait Retry-After seconds; the value is a hint, so back off on a repeat 429.

---

[API](https://skmtc.dev/gitcafe/apis/git-cafe-api.md) - [All operations](https://skmtc.dev/gitcafe/apis/git-cafe-api/llms.txt) - [OpenAPI document](https://skmtc.dev/gitcafe/apis/git-cafe-api/revisions/9fa233d2986d?raw)
