﻿# Personal access tokens

> A personal access token (PAT) lets scripts and integrations call the WorkSmartHub REST API in the name of a user. A PAT is a pair:

Source: https://workwise-solutions.net/docs/features/personal-access-tokens/ · Language: en · Hungarian version: https://workwise-solutions.net/hu/docs/features/personal-access-tokens/

A personal access token (PAT) lets scripts and integrations call the WorkSmartHub REST API in the name of a user. A PAT is a pair:

- the **access token** (*hozzáférési token*): short-lived (8 hours by default), sent with every API call;
- the **refresh token** (*frissítő token*): long-lived, used only to get a new access token. Every exchange returns a new pair, and the previous refresh token stops working, so always store the new one.

A PAT works only for API calls. It never starts a browser session, and a PAT cannot create other PATs.

![Personal access tokens](https://workwise-solutions.net/docs/images/diagram-pat-en.png)
*A token is created once, the refresh token is exchanged for new pairs, and the access token is sent with every API call.*

Menu: **Hozzáférési Token → Személyes Hozzáférési Tokenek**. Users who have only the *Public* permission see the page only if it is enabled in **App Konfiguráció → Oldal Láthatóságok**.

![Personal access tokens](https://workwise-solutions.net/docs/images/pat-list.png)
*The page explains the two tokens and shows the refresh endpoints of this installation with curl examples.*

## Creating a token

**Token létrehozása** opens the dialog:

| Field | Notes |
|---|---|
| PAT neve | Name of the token, for example the integration it is for. |
| Lejárati mód (Expiration mode) | **Abszolút**: the refresh token expires on a fixed date (UTC). **Gördülő** (rolling): the refresh token's lifetime starts again with every refresh. Rolling tokens can be turned off in App configuration. |
| Access Token Lejár | Lifetime of the access token, format `dd.hh:mm:ss`. |
| Lejárati figyelmeztetések | Optional warnings before expiry: pick an application-level notification channel and the number of days. |

![Creating a token](https://workwise-solutions.net/docs/images/pat-create.png)

After creation, a dialog shows the refresh token and the access token once. Copy them; they cannot be displayed again.

The default and maximum lifetimes are set in **App Konfiguráció → Hozzáférési tokenek**: by default the refresh token lives 90 days (at most 730) and the access token 8 hours (at most 48).

## Managing tokens

The list shows the name, status (*Aktív*, *Érvénytelen* invalidated, *Lejárt* expired), creation time, mode, and expiry of the refresh and access tokens. Actions:

- **Lejárati figyelmeztetés szerkesztése**: change the expiry warnings;
- **Érvénytelenítés** (Invalidate): the token stops working on every server within about a minute;
- **Törlés** (Delete): only for tokens that are no longer active, so invalidate first.

## Administration

Super Admins have **Admin Token Menedzsment** (*Személyes hozzáférési token admin felület*), which lists every user's tokens with the owner, and lets them invalidate and delete them. From the **Felhasználók** (and **Profilok**) rows they can also create a token for a user or list a user's tokens.

![Token administration](https://workwise-solutions.net/docs/images/pat-admin.png)

Changing `LoginSettings.JwtAuthenticationSettings.SymmetricSecurityKey` in `appsettings.json` ends every token and session at once.

See [API usage](https://workwise-solutions.net/docs/api-usage/) for how to call the API.
