Open WebUI OAuth token exchange for CLI and service access

Open WebUI token exchange lets approved scripts and services trade an identity provider access token for an Open WebUI session. This page covers the options, the setup sequence, the client ID restriction and the providers where that restriction cannot be enforced.

On this page

Why teams need OAuth token exchange for scripts and services

A team that has put people behind single sign-on often finds that its scripts, CI jobs and command-line tools still need a way into Open WebUI. Usually the workaround is a shared service password or a personal API key copied into a config file, and neither one ties the automated activity to an identity the organization can review or disable. OAuth token exchange is the pattern that closes that gap: a script or service presents an access token it obtained from the identity provider, and Open WebUI trades it for its own session, so the automation runs under a real, governed identity instead of a static secret.

In plain terms, the exchange works like this. The client obtains a token from the identity provider for a specific client ID, sends it to Open WebUI, and Open WebUI validates it against the configured provider and issues a session. Compared with API keys, token exchange fits best when the caller already has an identity in your directory, when group membership should decide what the automation can reach, and when you want the provider to control expiry and revocation. Long-lived API keys remain simpler for narrowly scoped integrations that have no identity provider behind them. The two mechanisms also differ in what a leak exposes, so the choice is a security decision, not only a convenience one.

The exact behavior is version-dependent. Whether token exchange is available, which client IDs can be trusted, how the audience and token lifetime are checked, and which providers support the restriction all depend on the Open WebUI release and its configuration. Before you design anything, read the Open WebUI features documentation for the release you run, and confirm the current release line against the project's GitHub releases page, where v0.12.3 is the latest release named in our research. Treat a build or a configuration example from a different release as a hypothesis to test, not a setting to copy.

Which access pattern fits each script or service

This table compares a personal API key, a token exchange from an identity provider access token, and a dedicated service account across ownership, revocation, scoping and identity provider needs. Read each row as a question to answer in your own test environment, since the researched documentation confirms API keys and OIDC sign-in but does not confirm every exchange setting. Choose the pattern only after you have verified the rows marked for testing.

QuestionPersonal API keyToken exchange for a script or serviceDedicated service account
Who owns the credentialThe user who created the key, so it stops working if that person leavesThe identity provider client and the user or workload whose token is exchanged; confirm which identity Open WebUI records as the session ownerThe organization, through a non-human identity that is provisioned and owned by the platform team
How it is revokedDelete or rotate the key in user settings or by an admin; confirm whether revocation is immediate across all replicasRevoke or disable the identity provider client or user, then confirm whether existing Open WebUI sessions end without Redis-backed revocationDisable the account at the identity provider and rotate its client secret or certificate; test that Open WebUI rejects the next exchange
How it is scopedLimited to what the owning user can do; confirm whether endpoint-level limits are available for keysLimited by the client ID allowlist and the claims Open WebUI accepts; confirm how allowed client IDs are configuredLimited by group membership and Open WebUI permissions assigned to one non-human account; design these before rollout
What it needs from the identity providerNothing beyond normal user sign-in, since the key is created inside Open WebUIA token issued to a listed client ID with the expected audience and claims; verify with the vendor docs and a test tokenA client that supports the chosen grant, a stable subject identifier and a group or claim mapping; confirm each with your identity provider
Audit trail clarityRequests trace to a person, which helps investigations but mixes personal and automated activityDepends on the claims carried into the session; test what appears in Open WebUI logs before relying on itRequests trace to one named automation identity that is easy to review and disable
Best fitOccasional personal scripts with low privilege and a short-lived needServices that already hold an identity provider token and must reach Open WebUI without a separate passwordRecurring automation, shared pipelines and integrations maintained by a team

How a script's identity provider token becomes an Open WebUI session

The flow starts on the script host, which asks the identity provider for an access token using a registered client_id. The script then presents that token to Open WebUI. Open WebUI validates the token with the identity provider and checks the token's client ID against its trusted list. Only a token from a listed client ID becomes an Open WebUI session. Any other token is refused. This is a general flow, and the exact endpoints, token format and validation method depend on the identity provider you choose.

General flow of a script's token exchange; endpoints vary by identity provider.

Setting up token exchange in order

This sequence moves from working human sign-in to a narrow, tested token exchange in which only registered service clients can obtain Open WebUI sessions. Each step closes with a check so the team knows the layer below is sound before adding the next.

  1. Confirm human single sign-on works first

    Before touching service access, sign a test user into Open WebUI through the identity provider you plan to use and confirm the expected user, email and group claims arrive. The identity team or platform owner does this with a named test account. Check that the session is created, that the user lands in the right Open WebUI group, and that sign-out behaves as expected. If any of these fail, fix the browser sign-in path first, because token exchange depends on the same provider configuration and claim mapping.

  2. Register a dedicated client for each service

    In the identity provider, create one client for each script or service that will exchange tokens, rather than sharing a single client across tools. Name each client after its owner and purpose so the audit trail is readable. Keep the client type and token settings as the identity provider documentation recommends for non-browser callers, and record which service owns each client. The check is a list of clients in the provider console with one entry per consumer and no shared credentials.

  3. Record each client ID for the allowlist

    Copy the exact client ID from each registered client into a controlled inventory with the owning team, the purpose, and the date it was approved. Treat this list as the source for the Open WebUI allowlist, so any later change goes through the same record. The check is that every ID in the inventory matches a client in the provider, and that no ID is included without an owner. Confirm the exact spelling, since a single character mismatch will either block the service or leave an unintended entry.

  4. Configure Open WebUI to trust only listed IDs

    Enable token exchange in Open WebUI and set the allowlist to the client IDs from the inventory, using the setting names in the Open WebUI documentation for the exact version you run. Do not rely on setting names from this outline, because they can differ between releases. Restart or reload the service as the documentation describes, then confirm the running configuration shows the intended IDs. The check is that a token from an unlisted client is refused while the listed client is still accepted by the same instance.

  5. Test with one client and a non-admin account

    Run the exchange from one registered client using an ordinary user account that has no administrator role, and confirm the returned Open WebUI session can reach only the models and resources that user is allowed to use. Repeat with a deliberately unlisted client to confirm it is refused. The test owner records each request, response and resulting user identity. The check is that the non-admin session cannot perform admin actions, and that the unlisted client produces a refusal in the logs.

  6. Confirm session lifetime and revocation

    Establish how long a service-issued session remains valid, then test what happens when the identity provider access is disabled or the client is removed. Check the Open WebUI documentation for the installed version on how sessions are stored and revoked. Note that the scaling guide states that without Redis, signing out does not revoke tokens, which remain valid until they expire, by default after 4 weeks. The check is a written result showing whether revocation takes effect immediately or at expiry, so the runbook reflects reality.

Security risks to design around before enabling exchange

Token exchange lets a script trade an identity provider token for an Open WebUI session, so every weak point in the identity chain becomes a path into the application. The cards below cover the client trust settings, session lifetime, account lifecycle, privilege, logging and shared state that connect those paths. Work through them before any automation receives an exchange.

Shared or over-permitted client IDs

Exchange should accept tokens only from client IDs you have listed explicitly. If one client ID is shared by a laptop tool, a CI job and a web app, a token issued for one purpose can open a session for another. Review each listed client ID, confirm which audiences and applications it serves, and remove any that no longer have an owner. Ask your identity team to confirm that the identity provider issues separate client IDs for each automation.

Tokens that survive sign-out

Without Redis, signing out of Open WebUI does not revoke tokens. They stay valid until they expire, by default after 4 weeks, so a session created by a script keeps working after the operator who started it has left. Confirm your Redis configuration before enabling exchange, and test that a sign-out actually ends access from a second client. Set the expiry deliberately rather than relying on the default.

Scaling docs

Sessions outliving the identity account

An exchanged session is only as current as the identity provider account behind it. A disabled user or a removed group membership can still hold a valid Open WebUI session until that session expires. Decide how long an exchanged session may live, and make disabling an account at the identity provider a step in your offboarding checklist. Ask whether the identity provider can revoke tokens or end sessions on your behalf.

Admin roles reaching automation

If the account behind a script holds an admin role, every exchanged session inherits those rights, including user management and settings changes. Create a dedicated service identity with the narrowest group membership that the job needs, and keep administrators out of automation accounts. Review which groups map to admin roles through claims, because a claim change at the identity provider can silently raise the privilege of a scripted session.

Tokens leaking into logs

Scripts, shell history, CI logs and reverse proxies can record bearer tokens in plain text, and a leaked token works until it expires. Keep tokens out of command-line arguments and debug output, pass them through a secrets store, and configure proxy access logs so that authorization headers are not written. Confirm that your logging pipeline redacts the headers used for exchange requests, and rotate any token that appeared in a shared log.

Shared state across replicas

When Open WebUI runs on several replicas, each one must see the same session state, or a token exchanged on one replica may be rejected or accepted inconsistently. Redis is the shared store for sessions and websocket connections, and PostgreSQL replaces SQLite for multi-instance setups. Before enabling exchange, confirm that every replica points at the same Redis and database, and test a sign-out against a different replica from the one that issued the session.

Scaling docs

When the client ID restriction cannot apply

Some identity providers let the operator limit which OAuth clients can obtain tokens for a given audience or resource, so only the clients you list can exchange a token with Open WebUI. This is the strongest position for the exchange, because the allow-list is enforced where tokens are minted rather than only at Open WebUI. Even here, treat the restriction as one control among several.

  • Allowed client IDs: Keep the list of client IDs that may present tokens to Open WebUI short, documented and owned by a named team.
  • Narrow audiences: Request tokens with an audience that identifies Open WebUI only, so a token issued for another service cannot be replayed against it.
  • Short lifetimes: Set access token lifetimes to the minimum your scripts can tolerate and confirm refresh behavior for service clients.
  • Change review: Route any change to the client list or token policy through the same approval path as other identity configuration.
  • Sign-in logs: Alert on token issuance for listed clients from unexpected networks or at unexpected hours.

Confirm with the provider's documentation or vendor which setting enforces the client restriction, whether it applies to service accounts, and whether it can be bypassed by administrators.

Limits to confirm in your environment

Token exchange depends on details that vary by release, identity provider and deployment layout. Each card below is a question to answer in a test environment before any script or service depends on the exchange in production.

Does your release support the exchange

Confirm that the Open WebUI version you run includes token exchange at all before you design around it. Open WebUI publishes new releases often, so check the release notes for the version you plan to deploy rather than relying on older documentation or community posts. Run a test exchange with a throwaway client on the same version and configuration you intend to use in production.

Open WebUI releases

Where the trusted client IDs are set

Find out how the list of accepted client IDs is supplied and whether a value saved through the admin interface overrides the environment variable. A persistent configuration can silently keep an old list after you change the deployment, so a client you removed may still work. Test by removing a client ID from the environment, restarting, and confirming the exchange is refused.

Token lifetime from the identity provider

Ask your identity provider how long it issues access tokens for the exchanged client and whether refresh tokens are issued at all. Open WebUI's own session lifetime is a separate setting. Without Redis, sign-out does not revoke tokens, and they remain valid until they expire, by default after 4 weeks. Measure the actual lifetime in your test rather than assuming the default.

Scaling Open WebUI docs

How revocation reaches exchanged sessions

Test what happens to an exchanged session when the user is disabled in the identity provider, when a client secret is rotated, or when an administrator removes the account in Open WebUI. Revocation that works for browser sessions may not reach sessions created by a script. Record the delay between the change and the first refused request.

Behavior across replicas

If you run more than one Open WebUI replica, confirm that an exchanged session is accepted by every replica and that revocation is applied everywhere. Open WebUI's scaling guide requires Redis as a shared state store for sessions when running multiple replicas. Send exchange and follow-up requests through the load balancer during testing and check for intermittent refusals.

Scaling Open WebUI docs

Client attribution in audit logs

Confirm whether Open WebUI's logs record which client ID made each exchange and each request made with the resulting session. Without that, an incident involving a leaked service credential cannot be traced to one script or service. Make a test call from a known client, then search the logs for its client ID and the user it authenticated as.

Choosing between token exchange and managed API keys

Choose a managed API key when one integration needs a narrow set of endpoints and a named owner can rotate the key on a schedule. The Open WebUI features documentation describes API keys as a documented access method for scripts and integrations. The key belongs to the integration, not to a person, so the owner's job is to store it in a secrets manager, record which endpoints it reaches, and replace it on a schedule or after any suspected exposure. For a small job, such as a nightly script that posts to one endpoint, this ownership model is simpler to run and easier to audit than a chain of tokens that depends on an identity provider.

Choose identity-based exchange when the automation must follow the identity provider's decisions. If a person is disabled, removed from a group, or blocked from an application at the identity provider, a service that exchanges that person's access token for an Open WebUI session should stop getting sessions once the change takes effect. A static key does not follow those changes. It stays valid until someone finds it and revokes it, and offboarding checklists rarely include every key a departing engineer created. Confirm the exact behavior in your version: whether group changes apply to existing sessions and how long an issued session lasts. The scaling documentation notes that without Redis, sign-out does not revoke tokens, which remain valid until they expire, by default after 4 weeks, so session lifetime belongs in the decision.

Settle ownership before choosing. Ask who is accountable for the credential, who is alerted when that person leaves, and whether a service account in the identity provider can own the automation so its access is reviewed like any other account. Then test offboarding in a staging instance: disable a test identity, run the automation, and record whether access stops and how quickly. If the answer depends on a token lifetime you cannot shorten or on a manual revocation step, the identity-based path needs more design work. Many teams use both: identity-based exchange for automation that acts on behalf of people, and a narrowly scoped key for a fixed integration with no human owner.

Questions teams ask before enabling token exchange

How much effort does token exchange setup take, and what drives it?

The effort depends less on the Open WebUI settings than on what surrounds them: changes at the identity provider, the number of client IDs you need to trust, how much testing each path gets, and whether you run several replicas. Each trusted client ID is a registration to create, document and review. Multi-replica deployments also need Redis as shared state, as the scaling guide requires, which adds infrastructure to build and monitor. Testing should cover every script or service, expired tokens and rejected client IDs. Ask any quote to break effort down by component, and to show which items are one-time work and which recur when clients are added or the identity provider changes.

Can our team set this up alone using the documentation?

A team with identity and Open WebUI experience can work from the public documentation, but the hardest parts are decisions the documentation does not make for you: which client IDs to trust, how far each one can act, and how to prove that rejected requests are actually rejected. Start with the features documentation to confirm how your version handles OIDC and API keys, and the scaling guide if you run replicas. Open WebUI releases change, so verify behavior against the exact version you deploy. Many teams have a partner review the design before building, then carry out the build and testing internally.

What do we need from our identity and Open WebUI administrators?

Both administrators have work that cannot be delegated to the other. The identity administrator creates and reviews the client registrations, decides which client IDs are accepted, and sets token settings and claims. The Open WebUI administrator controls the application configuration, the database and Redis settings, and who holds admin rights inside the application.

  • Identity administrator: client registrations, trusted client ID list, token lifetimes, claim mapping.
  • Open WebUI administrator: SSO settings, session storage, role assignments, test sign-ins and log review.

Both should join the design stage, because a client registration that looks correct in isolation can still grant more than intended. Ask the quote to name each responsibility and the time each person must commit during design and testing.

Do scripts need a service account to call Open WebUI?

Not necessarily. First decide whether the script needs a user identity at all. A script can run under a dedicated non-human identity at the identity provider or under a named user, and each choice changes how actions are audited and how access is revoked. Open WebUI also documents API keys, and some teams use keys for scripts and reserve token exchange for flows that already hold an identity provider token. Check the features documentation for key scoping and admin controls in your version. If you do create a service account, give it the smallest group membership that works, assign a named owner, and review it on a schedule.

How does revoking access work after a script or client is retired?

Revocation has two parts: stopping new exchanges, and ending sessions that were already issued. Removing a client ID from the trusted list or disabling its registration stops future exchanges. Sessions already issued remain a separate question. The scaling guide states that without Redis, signing out does not revoke tokens, which stay valid until they expire, by default after 4 weeks. Multi-replica deployments need Redis as shared session state, so your revocation design depends on that setup. Test it directly: disable a client, attempt an exchange, then confirm that an existing session behaves as you expect.

What would a fixed-scope review of token exchange cover?

A fixed-scope engagement agrees its scope, deliverables and timelines in writing before work starts, so the written scope is the document to read closely. For this topic, a complete scope should list the trusted client IDs and the identity provider settings behind them, the exchange path for each script or service, Redis and shared storage if replicas run, revocation and expiry tests, and the handover to your team. Where the review includes security testing, it should also name the environments tested and whether a retest is included. Ask for explicit exclusions, such as identity provider administration that stays with your staff. DeployOpen does not publish a price list, so a quote follows from that written scope.

What if our identity provider cannot enforce the client ID restriction?

Do not enable token exchange for that provider until you have a compensating control and test evidence for it. The design depends on Open WebUI accepting only listed client IDs, and not every provider may let you enforce that restriction in the way you need. Confirm the behavior in the provider's own documentation and in a test environment before go-live. Options to evaluate include leaving exchange off for that provider, issuing narrowly scoped API keys for scripts, or placing an access check in front of Open WebUI. Each option needs its own tests, and the choice should be recorded as a risk decision with an owner.

How DeployOpen scopes and delivers token exchange

DeployOpen treats Open WebUI OAuth token exchange as a scoped change to your identity setup, not a configuration toggle. We agree which identity provider, client IDs, scripts and services are covered, then build, test and document the exchange inside your own infrastructure so your security and identity teams can review it.

How we scope

  • Inventory the identity provider, Open WebUI version and each script or service that would exchange tokens.
  • List every client ID that may be trusted for exchange, and record which providers cannot enforce that restriction.
  • Agree in writing which tests, deliverables and handover items are included before any work starts.
  • Confirm with your identity team whether the engagement is fixed-scope or should be extended through a retainer.

How we build

  • Configure the exchange so only the listed client IDs can obtain an Open WebUI session, and verify rejection of all others.
  • Set token lifetimes and session revocation behavior, including whether Redis is needed for sign-out to revoke tokens.
  • Test the exchange with positive and negative cases, including tokens from unlisted clients and expired tokens.
  • Document the configuration, environment variables and any provider limitations found during testing.

How we hand over

  • Deliver the configuration, the client ID allowlist and a written record of the provider limitations we found.
  • Walk your platform and identity engineers through the exchange flow, the tests and the rollback steps.
  • Provide a runbook for rotating credentials, adding a client ID and revoking a compromised script or service.
  • Record which checks your auditors or compliance team may ask to see, without issuing any audit conclusion ourselves.

How we support

  • Offer ongoing support, upgrades and continuous testing as a retainer when the exchange must track new Open WebUI releases.
  • Retest the exchange after each Open WebUI upgrade or identity provider change, within the agreed scope.
  • Review new client IDs and service accounts against the allowlist before they are added.
  • Ask us to confirm the support terms and response expectations in the written agreement before work begins.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.