---
title: "Generate Token"
method: POST
path: "/api/auth/token"
tags: ["Authentication Service"]
---

# Generate Token

`POST /api/auth/token`

Authenticate using **Basic Authentication** with username/password or client credentials.

This endpoint is typically used by a web or mobile application at login when the user first enters their credentials.

Returns an **access_token** and, optionally, a **refresh_token** depending on the type of authentication.

**Note: The refresh_token is only issued for web or mobile authentication users; it is not returned for machine-to-machine (M2M) authentication**.

**Header example**:
```
Authorization: Basic base64(username:password)
```

## Response `200`

Token generated successfully

- OAuth2TokenResponse — Represents the response returned after a successful authentication.
  - `access_token` string — JWT access token used to authenticate API requests.
  - `token_type` string — The type of token issued, typically 'Bearer'.
  - `expires_in` integer — The number of seconds until the access token expires.
  - `refresh_token` string — Refresh token used to obtain a new access token. Previous refresh_token expires once a new one is issued.

## Other responses

- `401` — Invalid username or password
- `500` — Internal server error

---

[API](https://skmtc.dev/civikestpayment/apis/tpe-authentication-api.md) · [All operations](https://skmtc.dev/civikestpayment/apis/tpe-authentication-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/civikestpayment/tpe-authentication-api/revisions/cc52506f2753/schema)
