> ## Documentation Index
> Fetch the complete documentation index at: https://www.truefoundry.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sign-in and credential refresh for MDM rollouts

> Choose how employees sign in to the AI Gateway under MDM, see the sign-in popup and warning they get, and learn how keys, sessions, MCP servers, and Skills stay current.

This page explains how employees stay signed in after an [MDM rollout](https://www.truefoundry.com/docs/ai-gateway/mdm-setup.md): which sign-in method to choose, what employees see when they need to act, and how credentials, MCP servers, and Skills are kept up to date without a browser. It requires `tfy-local-ai-setup` v3.0.2 or later.

## Choose a sign-in method

For most rollouts, use an **auto-renewed personal access token**. A personal access token (PAT) is a TrueFoundry token that belongs to one employee and carries their permissions. Choose OIDC if your organization requires every sign-in to go through its identity provider.

| Method | Set in `mdm.toml` | Best for | Keep in mind |
| - | - | - | - |
| **Personal access token, auto-renewed** (recommended) | `mode = "api-key"` and `auto_renew = true` | Most rollouts. Employees sign in once, and their token renews itself before it expires | Your organization's PAT limits apply: the maximum expiry, and a team on each token if you require one |
| **Browser sign-in session** | `mode = "api-key"` (the default) | Organizations that don't want PATs. No PAT is created, and the session refreshes itself | Employees sign in again after 30 days without a successful MDM run |
| **OIDC single sign-on** | `mode = "oidc"` and `[auth.oidc]` | Organizations that require sign-in through their identity provider. Short-lived tokens, no PAT to manage | Doesn't work with [Claude or ChatGPT subscriptions](#claude-and-chatgpt-subscriptions). Needs an [OIDC client](https://www.truefoundry.com/docs/ai-gateway/mdm-setup.md#set-up-oidc-sign-in). Employees sign in again when their IdP session ends |

The first two methods both use `mode = "api-key"`, which is the setting's name in `mdm.toml`. `auto_renew` chooses between them.

### Claude and ChatGPT subscriptions

> [!WARNING]
>
> **Subscriptions don't work with OIDC.** If you bill Claude Code to employees' [Claude Enterprise or Team seats](https://www.truefoundry.com/docs/ai-gateway/mdm/claude.md#use-a-claude-enterprise-or-team-subscription), or Codex to their [ChatGPT Business or Enterprise seats](https://www.truefoundry.com/docs/ai-gateway/mdm/codex.md#use-a-chatgpt-business-or-enterprise-subscription), use a personal access token or a browser sign-in session.
>
> * **Codex:** with OIDC, `auth_mode = "chatgpt-subscription"` fails validation, and the run stops with a configuration error.
> * **Claude Code:** with OIDC, Claude Code sends the TrueFoundry token in place of the employee's Claude login, so their seat is never used. Setup doesn't warn about this, so check your sign-in method before you roll out.

### Recommended configuration

Add these lines to your `mdm.toml`:

```toml mdm.toml theme={"dark"}
mcp_servers = ["@all"]
skills = ["@all"]

[auth]
mode = "api-key"
auto_renew = true
pat_expiry_days = 90

[background]
enabled = true
interval = "hourly"
```

`auto_renew` is off by default, so set it explicitly; without it, employees get browser sign-in sessions.

Each employee signs in once in the browser. Setup then creates a PAT for them, stores it on their device, and renews it before it expires. `pat_expiry_days` accepts 7 to 3650 days and defaults to 365. Your organization's maximum PAT lifetime still applies, and a change takes effect the next time a key is created or renewed.

Keep `mcp_servers` and `skills` at the top of the file, before the first `[table]` line.

### Use browser sign-in sessions instead

Replace the `[auth]` table with:

```toml theme={"dark"}
[auth]
mode = "api-key"
auto_renew = false
```

### Use OIDC instead

Follow [Set up OIDC sign-in](https://www.truefoundry.com/docs/ai-gateway/mdm-setup.md#set-up-oidc-sign-in) to create the client and add `[auth.oidc]` to `mdm.toml`. What employees see with OIDC is described [there](https://www.truefoundry.com/docs/ai-gateway/mdm-setup.md#what-employees-see-with-oidc).

* **Claude Code, Codex (CLI and desktop app), and Claude Desktop** sign in through OIDC directly. Other agents don't, so prefer a personal access token or a browser sign-in session if your fleet uses a wider mix of agents.
* **Don't set `auto_renew` with OIDC.** No key is created, and the file fails validation.
* **Claude Desktop with `@all`:** when MCP servers, Skills, or additional models use `@all`, signing in to Claude Desktop also lets MDM runs look them up in the background.

## What employees see

MDM runs never open a browser. When an employee needs to sign in, a background job in their session asks them with a popup. This also covers the first sign-in on a new device: the popup appears the next time the job runs, within an hour by default.

> [tab] Personal access token
>
> ![TrueFoundry popup saying the sign-in has expired, with Later and Sign in buttons and the tfy-local-ai-setup login --mdm command](https://mintcdn.com/truefoundry/1iSoImVPRmOlL-tY/images/ai-gateway/mdm/sign-in-popup.png?fit=max\&auto=format\&n=1iSoImVPRmOlL-tY\&q=85\&s=ec83d6bb719e143d613d7f5e70aaa00b)
>
> The sign-in popup with an auto-renewed personal access token.
>
> Employees can also sign in from a terminal with `tfy-local-ai-setup login --mdm`.

> [tab] Browser sign-in session
>
> ![TrueFoundry popup asking the employee to sign in to keep their AI tools connected, with Later and Sign in buttons](https://mintcdn.com/truefoundry/1iSoImVPRmOlL-tY/images/ai-gateway/mdm/sign-in-popup-device-login.png?fit=max\&auto=format\&n=1iSoImVPRmOlL-tY\&q=85\&s=2863459b8c4cd9a192c174273aec02c9)
>
> The sign-in popup with browser sign-in sessions.

* **Sign in** opens the browser with a fresh code. After the employee approves it, the next MDM run updates their agents.
* **Later** asks again in 24 hours.
* **No answer** within two minutes asks again in 4 hours.

Only one popup shows at a time. On Linux it is a notification with the same buttons, and on Windows a toast that stays until the employee picks a button.

### Renewal warning

If a key can't be renewed without help, for example because your organization requires a team on each token and the employee isn't in one, the employee sees a warning at most once a day. It has no buttons, and the job keeps retrying.

![macOS notification from TrueFoundry saying that managed key renewal failed and will be retried, because the employee isn't in a team](https://mintcdn.com/truefoundry/1iSoImVPRmOlL-tY/images/ai-gateway/mdm/renewal-warning-banner.png?fit=max\&auto=format\&n=1iSoImVPRmOlL-tY\&q=85\&s=ee557bef387ae66e48764a5905666917)

The warning shown when a key can't be renewed automatically.

To fix it, add the employee to a team, or review your organization's PAT settings. If the key expires before it is fixed, the employee signs in again from the popup.

## How refresh works

Two schedules keep everything current: the **background job** that the MDM run installs for each employee, and **your scheduled MDM run**.

| What | Refreshed by | When |
| - | - | - |
| **Personal access token** (auto-renewed) | Background job | Halfway through the key's life for keys of 30 days or less. For longer keys, when a quarter of its life is left, for example around day 274 of a 365-day key |
| **Browser sign-in session** | Each MDM run | On every run. After 30 days without a successful run, the employee signs in again |
| **OIDC session** | The agent, when it needs a token | On demand, until your OIDC client's `refresh_token_ttl` passes without use |
| **MCP servers, Skills, and models set to `@all`** | Each MDM run | On every run |

* **A renewed key reaches agent settings on the next MDM run.** The previous key stays valid for up to 7 days, so agents keep working in between.
* **Refreshes never open a browser.** If sign-in is unavailable or a lookup fails, the current settings stay in place and the next run retries.
* **`@all` deploys what each employee can access.** Employees may still need to authorize individual MCP servers inside their agent, and Claude Desktop Skills are uploaded as ZIP files. See [Add MCP servers and Skills](https://www.truefoundry.com/docs/ai-gateway/mdm-setup.md#add-mcp-servers-and-skills).

## Background job

The MDM run installs the background job for each employee and keeps it up to date. Keep both schedules running:

| | Background job | Scheduled MDM run |
| - | - | - |
| **Runs as** | The employee, in their session | Administrator: root or SYSTEM |
| **Scheduled by** | The MDM run, automatically | Your MDM; hourly is recommended |
| **Does** | Renews the PAT and asks the employee to sign in or act when needed | Writes agent settings, applies renewed credentials, and refreshes `@all` lists |

The background job alone does not update agent settings, so keep scheduling the MDM run. To change the job, set the `[background]` table:

```toml mdm.toml theme={"dark"}
[background]
enabled = true       # false removes the job on the next MDM run
interval = "hourly"  # or "daily"
```

The job uses each operating system's own scheduler:

* **macOS:** a LaunchAgent, `com.truefoundry.ai-setup.user`
* **Linux:** a systemd user timer, `truefoundry-ai-setup-user.timer`
* **Windows:** a Task Scheduler task, `\TrueFoundry\AI Setup User`

It runs a copy of the binary that only administrators can change. For the exact paths, see [Files written](https://www.truefoundry.com/docs/ai-gateway/mdm/configuration-reference.md#files-written).

On Linux, the job starts at once if the employee's session is running, otherwise at their next login. If an employee had set up background updates through [personal setup](https://www.truefoundry.com/docs/ai-gateway/personal-setup.md), the MDM run replaces that job on macOS and Windows.

> [accordion] Run the job now on a pilot device
>
> To show the popup without waiting for the next scheduled run, start the job as the employee:
>
> ```bash macOS theme={"dark"}
> launchctl kickstart gui/$(id -u)/com.truefoundry.ai-setup.user
> ```
>
> ```bash Linux theme={"dark"}
> systemctl --user start truefoundry-ai-setup-user.service
> ```
>
> ```powershell Windows theme={"dark"}
> schtasks /run /tn "\TrueFoundry\AI Setup User"
> ```

## Related

> [card] [Deploy coding agents with MDM](https://www.truefoundry.com/docs/ai-gateway/mdm-setup.md)
>
> Write `mdm.toml`, create the deployment script, and roll out to your fleet.

> [card] [Configuration reference](https://www.truefoundry.com/docs/ai-gateway/mdm/configuration-reference.md)
>
> Every `auth` and `background` field, with defaults and accepted values.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.