---
title: "تبادل کد با توکن / نوسازی توکن (RFC 6749)"
method: POST
path: "/oauth/token"
tags: ["oauth"]
---

# تبادل کد با توکن / نوسازی توکن (RFC 6749)

`POST /oauth/token`

## Request

- Base URL: `https://barchin.net/api`
- URL: `https://barchin.net/api/oauth/token`
- Auth: none declared

بدنه‌ی application/x-www-form-urlencoded (JSON هم پذیرفته می‌شود). grant_type=authorization_code با code, redirect_uri, client_id, client_secret, code_verifier (PKCE S256)؛ grant_type=refresh_token با refresh_token, client_id, client_secret و scope اختیاریِ محدودتر. احراز هویت برنامه با HTTP Basic هم ممکن است. هر refresh جفت تازه می‌دهد و قبلی را باطل می‌کند؛ استفاده‌ی دوباره از refresh_token قدیمی همه‌ی توکن‌های آن زنجیره را باطل می‌کند. سقف: ۳۰ درخواست در دقیقه برای هر IP و هر client_id.

## Response `200`

Successful Response

- AppSchemasOauthTokenOut
  - `access_token` string, required: bko_…؛ ۳۰ روز اعتبار.
  - `token_type` 'Bearer'
  - `expires_in` integer, required: ثانیه (۲۵۹۲۰۰۰ = ۳۰ روز).
  - `refresh_token` string, required: bkr_…؛ ۱۸۰ روز اعتبار، یک‌بارمصرف (هر refresh جفت تازه می‌دهد).
  - `scope` string, required: scopeهای اعطاشده، با فاصله.

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `429`: Too Many Requests

---

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