> ## Documentation Index
> Fetch the complete documentation index at: https://flashapi.phs.vn/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Cơ sở

Tạo access token, refresh token và OTP token cho tài khoản underlying.

### Endpoint

```text theme={null}
POST /oapi/auth/gen-secret-key/underlying
```

### Các trường bắt buộc

* `username` — Tên đăng nhập của tài khoản. Ví dụ: `022C099995`
* `password` — Mật khẩu của tài khoản. Ví dụ: `123456aA@`

### Trường phản hồi

* `access_token` (`string`) — Access token dùng cho các yêu cầu đã xác thực.
* `refresh_token` (`string`) — Refresh token dùng để gia hạn phiên đăng nhập.
* `expires_in` (`number`) — Thời gian tồn tại của access token, tính bằng giây.
* `otp_token` (`string`) — OTP token trả về từ luồng xác thực.
* `token_type` (`string`) — Loại token. Ví dụ: `Bearer`

### cURL

```bash theme={null}
curl -X POST "$BASE_URL/oapi/auth/gen-secret-key/underlying" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "022C099995",
    "password": "123456aA@"
  }'
```

### Python

```python theme={null}
import requests

BASE_URL = "https://api.example.com"

payload = {
    "username": "022C099995",
    "password": "123456aA@",
}

response = requests.post(
    f"{BASE_URL}/oapi/auth/gen-secret-key/underlying",
    json=payload,
)
response.raise_for_status()

print(response.json())
```

### Ví dụ phản hồi

```json theme={null}
{
    "access_token": "022C099995||KRYRTHUYUI||EIfMSnb0jB9MxpGEmVHV4Ghhiq6Tf9iKknzM02IYfYsLTpfTk3pDFPcR6WJqFepDFWXkQeLEpy9ifffm9NEhT9mDdjfHZDGwR7qwifvY1xUI00qe1pwLg9EY2ADJaBfqtsiEP7o6tDVae9lu2vrlq8GsZAKxLgloI8gibxqgPx0mitckPgNH7zjbyIoGKKNOzgErMP777bAWNIta0fnYmqLW7CleiXHtfJLIlXUruAMX5wxX7Gts7Tk4SiGpC9L",
    "refresh_token": "022C099995||KRYRTHUYUI||WSSb0xaoaWbcmCnqxGcJa5MfjElhnQo6G31b6Ay1yavoIgwLOVxm9nUWQIjix0XfYYaxFLJshAS6foc535ai2r1Mzh7OnEGoCKg3bMh32Y0ds5PRT3ySWck2XCuOZYffYOwgIvqIEjA49vCBa0UPuUOwwnPtdp3yK3E49CkPzn2CgyxFgRJxpZ4oezzgyA5fPqcm9h7jSaKIHWcG7vTc9aTDdhmt0SOkdEDc5sAx4nEWEeFxfdbPtXGKR0tx0mLh",
    "expires_in": 28800,
    "otp_token": "552066a35eb30a9815afc952b14287a8",
    "token_type": "Bearer"
}
```

### Error response

```json theme={null}
{
    "code": "OAPI_EQT_500",
    "messageParams": {
        "error": "server_error",
        "error_description": "-107 Tên đăng nhập hoặc mật khẩu không đúng",
        "s": 500
    },
    "params": null,
    "source": "oapi-bridge-eqt",
    "message": null
}
```

> Thay `BASE_URL` bằng host API của bạn. Thông báo lỗi từ hệ thống phía sau có thể được trả về bằng tiếng Việt.
