Skip to content
Login

Connect AI apps (MCP) with OAuth

AI apps that support remote MCP servers sign in with OAuth. HLE can be that sign-in for any endpoint: you turn on Connected apps, give the app your MCP address, and approve it once. Your MCP server needs no OAuth code of its own.

  1. The app calls https://<your-endpoint>/mcp.
  2. HLE answers that the request needs a token, and tells the app where to get one on your endpoint’s own address.
  3. You sign in to HLE and approve the app.
  4. The app gets a token that works only on that endpoint.
  5. On every request, HLE checks the token and passes the request on without the token.

Open the endpoint — Connections → Tunnels or Connections → Agents — then its Access Control tab, find the Connected apps section, and turn it on. Copy Address to give the app; that is what you paste into the AI app.

Four settings control what happens:

  • What is protected — Only these paths (default /mcp; add up to ten) or The whole endpoint. A request to a protected path needs an app token, or a sign-in your rules already allow; everything else follows the rules above it. On a protected path HLE never forwards an Authorization header to your service, whatever it contains.
  • Who can approve — You, or anyone your rules above allow by email, or Only you.
  • Self-registering apps — Off (only apps with a client ID you create), Known AI apps only (Claude, ChatGPT and Gemini, plus apps on your own computer; the default), or Any app.
  • Send identity to your service — adds X-HLE-App-User (the approver’s email) and X-HLE-App-Client to requests that arrive with an app token. HLE removes any copies of these headers a client sends, so your service can trust them.

Under Client IDs, choose Add app and pick Claude, ChatGPT, Gemini or Other. The dashboard shows the client ID, and — when the app keeps a secret — the client secret once. Copy the secret immediately: it is never shown again.

In Claude’s settings, open Connectors, add a custom connector, and paste the address from Address to give the app. Connect, then approve the app on HLE when it asks. Claude’s menu names can change, so look for the custom-connector setting if the wording differs.

With Self-registering apps at the default (Known AI apps only), Claude registers itself and nothing else is needed. With Off, create a Claude client ID first and paste its client ID and secret into the connector’s Advanced settings.

For Claude Code, add the endpoint and then sign in:

Terminal window
claude mcp add --transport http <name> https://<your-endpoint>/mcp

Run /mcp in Claude Code to sign in. It uses a callback on your own computer, which the default allows; the approval page then says you will return to “an app on this computer”.

Apps that are not Claude, ChatGPT or Gemini are marked Unverified app on the approval page. Approve one only if you started the connection yourself.

Create a connector in ChatGPT (developer mode or a custom connector), paste the address, and choose OAuth. ChatGPT registers itself, so you only approve it on HLE. ChatGPT’s menu names can change, so look for the connector settings if the wording differs.

With Self-registering apps at Off, create a ChatGPT client ID first and paste its client ID and secret into the connector.

Gemini needs a client ID. Create a Gemini client ID under Client IDs. The dialog that shows the client secret (once) also shows the MCP server URL.

In Gemini, choose to connect an MCP server, paste the MCP server URL, open Additional settings, and paste the Client ID and Client secret. Choose Next, then approve Gemini on HLE. Gemini finds everything else on its own. You do not need to copy its redirect URI into HLE: the Gemini client ID already accepts Google’s return addresses.

Gemini Enterprise’s connector asks for more fields. Open Gemini Enterprise asks for more in the same dialog for the Authorization URL, Token URL and Scopes (tunnel). Turn PKCE on and leave the authorization URL parameters empty.

The first sign-in locks the return address. Gemini’s return address is not fixed, so HLE accepts the first one Gemini uses and locks it. The client ID row shows Not signed in yet until then and Locked to Gemini’s return address afterwards; both are normal. The row updates by itself within a few seconds of the sign-in. If you need a different return address, delete the client ID and create a new one.

Gemini Enterprise is covered by the same preset.

Choose Other for a client ID with up to five return addresses of your own: https anywhere, or http://127.0.0.1 / http://localhost for a local tool. Give it a secret or leave it public.

An OAuth client needs:

  • Discovery at https://<your-endpoint>/.well-known/oauth-protected-resource (or https://<your-endpoint>/.well-known/oauth-authorization-server).
  • Authorization code flow with PKCE (S256).
  • Client authentication with client_secret_basic, client_secret_post, or none.
  • Refresh tokens.
  • The revocation endpoint.

To refresh an access token, POST to the token endpoint:

Terminal window
curl -X POST "https://<your-endpoint>/_hle/oauth/token" \
-d grant_type=refresh_token \
-d client_id=hlec_example \
-d refresh_token="<refresh token>"
  • Tokens are bound to one endpoint and its protected paths.
  • Access tokens last one hour; refresh tokens expire after 90 days unused, and at most one year after you approve the app.
  • Refresh tokens rotate. For an app without a client secret, replaying an old refresh token disconnects the app.
  • Disconnecting an app closes its open connections, including WebSockets, straight away. A connection opened with a token also closes when that token expires, and the app reconnects with a fresh one.
  • PKCE (S256) is always required.
  • HLE never forwards the app’s token, or its own cookies, to your service.
  • Approving an app needs a signed-in HLE account that your rules allow.
  • Removing someone from your email rules disconnects the apps they approved.
  • Revoke all disconnects every app on the endpoint at once.
  • Turning Connected apps off pauses every token on the endpoint without deleting the approvals; turning it back on resumes them.
  • Client secrets are shown once and stored only as a hash.
  • HLE records approvals and revocations in your access log (the Connected apps rule line) and in the account audit.
  • What HLE stores for each approval: the approver’s email, the app’s name and identifier, the endpoint and paths it may use, its return address, and when it was approved, last refreshed, last used and disconnected. Tokens are stored only as fingerprints, and the record holds no IP address. Records are deleted 30 days after the app is disconnected or its access expires.

Under Account → Connected apps you see every app you approved, on any endpoint, with a Disconnect button for each one.

The app says it cannot find an authorization server

Section titled “The app says it cannot find an authorization server”

Connected apps is off, or the address does not include the protected path. Check the address against Address to give the app. The endpoint must be online for the app to reach discovery. If the app reports a temporary error (HTTP 503) while signing in or refreshing, the service is offline or Connected apps is paused; the app keeps its approval and retries.

“This app asked to return to an address that is not allowed for it”

Section titled ““This app asked to return to an address that is not allowed for it””

The app’s return address is not registered for it. Check Recent sign-ins this endpoint refused in the panel for the address and the reason. For a self-registering app, switch Self-registering apps to Any app — but only if you trust who can approve.

The client ID was deleted or mistyped, or Self-registering apps is off and the app did not use a client ID you created.

Approve button missing, or “You are not on the list”

Section titled “Approve button missing, or “You are not on the list””

Who can approve excludes you. Add the person’s email to the endpoint’s access rules, and set Who can approve to include them.

The app was revoked, Revoke all was used, the approver was removed from your rules, Connected apps was turned off, or the refresh token expired after 90 days unused. Reconnect from the app.

By design — on a protected path HLE does not forward any Authorization header, so your service never sees the app’s token. Turn on Send identity to your service to receive X-HLE-App-User and X-HLE-App-Client instead.

Browser visits to /mcp show a 401 JSON instead of the sign-in page

Section titled “Browser visits to /mcp show a 401 JSON instead of the sign-in page”

This is expected on a protected path: it answers OAuth clients, not browsers. A browser already signed in through your rules still gets through.