---
title: "Generate OAuth 2.0 access token using authorization code or refresh token"
method: POST
path: "/oauth/token"
tags: ["oauth"]
---

# Generate OAuth 2.0 access token using authorization code or refresh token

`POST /oauth/token`

## Request

- Base URL: `https://docs-api.formify.eu/v1`
- URL: `https://docs-api.formify.eu/v1/oauth/token`
- Auth: one of:
  - HTTP basic
  - none

This endpoint is used to exchange an authorization code or refresh token for an access token. 

### Notes:
- The **Authorization Code Grant Flow** requires a `grant_type` of `authorization_code` and a valid `code` obtained from the authorization URL.
- The **Refresh Token Grant Flow** requires a `grant_type` of `refresh_token` and a valid `refresh_token`.
- Traditional clients authenticate using **HTTP Basic Authentication**: send `Authorization: Basic base64(client_id:client_secret)`.
- Public clients (URL-based `client_id`) do not send credentials in the header — instead, send `client_id` in the request body.

### Public clients (Client ID Metadata Document)

If your `client_id` is an HTTPS URL pointing to a metadata document, do not send a `client_secret`. Instead, include a `code_verifier` (PKCE) when exchanging an authorization code. See the [OAuth for AI & Third-Party Clients](/guides/oauth-for-ai/) guide.

## Response `200`

Token generated successfully

- object
  - `access_token` string: The access token.
  - `expires_in` integer: The number of seconds until the access token expires.
  - `refresh_token` string: The refresh token.
  - `token_type` string: The type of token.
  - `scope` string: Space-separated list of permissions granted to this token (e.g. `read`, `write`, or `read write`).

## Other responses

- `400`: Missing or invalid request
- `401`: Unauthorized - Invalid client credentials.
- `500`: Internal server error

---

[API](https://skmtc.dev/formify/apis/formify-api.md) · [All operations](https://skmtc.dev/formify/apis/formify-api/llms.txt) · [OpenAPI document](https://skmtc.dev/formify/apis/formify-api/revisions/571c4c0d4f4f?raw)
