# 액세스 토큰 교환: client_credentials(client_id = 채널 코드, client_secret = 시크릿) 또는 password(username = OMS 로그인 계정, password = OMS 비밀번호) → Bearer access_token

`POST /api/v1/auth/token` — 토큰 불필요

인증

## 요청 본문(JSON)

| 필드 | 타입 | 설명 |
| --- | --- | --- |
| `grant_type` | string | OAuth2 grant type: client_credentials(채널 코드 + 시크릿) 또는 password(OMS 계정 + 비밀번호). 생략 가능: username 이 있으면 password 로, 없으면 client_credentials 로 처리합니다. |
| `client_id` | string | 채널 코드(OAuth2 client_id). 담당자가 발급하며 client_credentials 방식에 사용합니다. 먼저 써 보려면 sandbox 를 쓰세요. (최대 길이 32 · 형식 ^[A-Za-z0-9_-]+$) |
| `client_secret` | string | 채널 시크릿(OAuth2 client_secret). client_credentials 방식에 사용합니다. 먼저 써 보려면 sandbox 를 쓰세요(샌드박스는 데모 데이터만 반환하고 실제 재고를 건드리지 않습니다). (최대 길이 256) |
| `username` | string | OMS 웹사이트 로그인 계정(password 방식), 예: 100470admin. 시스템 연동용 하위 계정을 따로 만드는 것을 권장합니다. 먼저 써 보려면 sandbox 를 쓰세요. (최대 길이 64) |
| `password` | string | OMS 로그인 비밀번호(password 방식). 토큰 교환 시점에만 사용되며 게이트웨이는 저장하거나 기록하지 않습니다. 먼저 써 보려면 sandbox 를 쓰세요. (최대 길이 256) |

## 응답

봉투는 HTTP 상태 코드만으로 판단합니다: 2xx 는 `{ data: … }`(목록은 `page / page_size / has_more` 또는 `total_count` 포함); 4xx / 5xx 는 `{ error: { code, message, hint, request_id, doc_url } }`.

```json
{
  "data": { "access_token": "eyJhbGciOi…", "token_type": "Bearer", "expires_in": 3600, "expires_at": "2026-09-03T06:27:28.000Z" }
}
```

성공 응답에는 사람이 읽는 문구가 없습니다 — `code / result / msg` 없음. 프로그램이 분기해야 할 필드는 `error.code` 뿐이며 `message` 는 `Accept-Language` 를 따릅니다.

## 예제

### curl

```bash
curl -X POST "https://connect.everugg.net.au/api/v1/auth/token" \
  -H "Content-Type: application/json" \
  -d '{ "grant_type": "client_credentials", "client_id": "<채널ID>", "client_secret": "<시크릿>" }'
```

### Python

```python
import requests

r = requests.post(
    "https://connect.everugg.net.au/api/v1/auth/token",
    json={
      "grant_type": "client_credentials",
      "client_id": "<채널ID>",
      "client_secret": "<시크릿>"
    },
)
data = r.json()
r.raise_for_status()  # 4xx/5xx: data["error"]["code"] / ["hint"]
```

### Node

```js
const res = await fetch("https://connect.everugg.net.au/api/v1/auth/token", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "grant_type": "client_credentials",
    "client_id": "<채널ID>",
    "client_secret": "<시크릿>"
  }),
})
const data = await res.json()
if (!res.ok) throw new Error(`${data.error?.code}: ${data.error?.message}`)
```

### Java

```java
HttpRequest req = HttpRequest.newBuilder()
    .uri(URI.create("https://connect.everugg.net.au/api/v1/auth/token"))
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString("{ \"grant_type\": \"client_credentials\", \"client_id\": \"<채널ID>\", \"client_secret\": \"<시크릿>\" }"))
    .build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
```

---
Markdown 원본: https://connect.everugg.net.au/reference/post-api-v1-auth-token.md?lang=ko · 웹 페이지: https://connect.everugg.net.au/reference?op=post-api-v1-auth-token&lang=ko
