Skip to main content

Okta Auth for ChatGPT MCP Servers with Datawiza Agent Gateway

About 11 min

Overview

This tutorial shows how to add Okta authentication to an existing MCP server using Datawiza Agent Gateway — without modifying the server itself.

Datawiza Agent Gateway sits in front of your MCP server, handles the Okta login flow, validates the user, enforces access policy, and forwards only authenticated MCP traffic to the backend. Your MCP server stays focused on its tools and never needs to implement enterprise OAuth.

Architecture

Architecture diagram — Datawiza Agent Gateway between ChatGPT and the internal MCP server

MCP over HTTP supports authorization at the transport layer. Protected MCP servers can require OAuth-style bearer tokens before granting access to tools. Since authorization is optional in the MCP spec, many internal servers skip it entirely — which is exactly where a gateway pattern adds value.

What You Will Build

By the end of this tutorial you will have a Datawiza-protected public endpoint sitting in front of your existing internal MCP server:

https://crm-mcp.company.com/mcp     ← protected endpoint ChatGPT connects to
http://internal-crm-mcp:3000/mcp    ← your existing MCP server (stays internal)

ChatGPT connects only to the protected endpoint. The internal MCP server is unreachable from outside your network.

The examples throughout this tutorial use a sample internal CRM server as the backend. This is illustrative — you will substitute your own MCP server. The sample server exposes three tools:

ToolDescription
get_customer_profileRetrieve a customer's profile by ID
list_customer_ordersList recent orders for a customer
create_support_ticketOpen a support ticket on behalf of a customer

Why This Pattern Matters

Many MCP servers are easy to build but do not include enterprise-grade authentication. This is risky when tools expose CRM records, orders, tickets, finance data, or internal APIs.

With Datawiza Agent Gateway, responsibilities stay separate:

  • MCP server developers build business tools.
  • Identity teams manage authentication and access policy.
  • ChatGPT users authenticate with Okta before any tool is available.

Prerequisites

  • An Okta organization (developer or production) with admin access

  • Permission to modify Okta's default Authorization Server (add a scope and, if needed, an access policy rule) and to create App Integrations

  • A Datawiza Agent Gateway Console (DAGC)open in new window account

  • A Linux host reachable from the internet on port 443 to run the gateway container

  • Docker and Docker Compose installed on the gateway host (the setup script in Step 2.5 can install these for you)

  • A public hostname for the protected MCP endpoint

  • A TLS certificate from a trusted CA for that hostname

  • An existing MCP server accessible on your internal network

  • A ChatGPT Plus, Pro, Business, or Enterprise plan with custom MCP connectors available (some plans gate this behind a Developer mode setting — see Step 3)

    Write-capable tools may be restricted on some plans

    OpenAI's own documentation is inconsistent about which plans support write-capable (not just read/fetch) MCP tools — some pages describe full support on Plus/Pro, others reserve it for Business/Enterprise/Edu. This tutorial's sample server includes create_support_ticket, a write action, so if you're on Plus or Pro, verify that tool actually runs in your account before relying on this pattern for write operations.

Step 1: Configure Okta

Okta separates MCP authorization across two objects:

  • The Authorization Server, which defines the audience, issuer, and scope the protected MCP endpoint accepts — the resource side. This tutorial reuses Okta's built-in default Authorization Server rather than creating a dedicated one, so there's less to provision and maintain.
  • An App Integration, which is what ChatGPT actually signs users into — the client side, holding the redirect URI and requesting the Authorization Server's scope on the user's behalf.

This mirrors standard OAuth practice: the Authorization Server is never involved in a browser redirect, and the App Integration never defines API scopes directly.

Default vs. custom Authorization Server

The default Authorization Server is shared org-wide — other apps in your Okta tenant may already issue tokens from it. That's fine: adding a scope to it doesn't grant that scope to anyone automatically, and Step 1.4 locks down which client can actually obtain it. If you'd rather keep this MCP integration fully isolated from other apps sharing default, create a dedicated custom Authorization Server instead (Security > API > Add Authorization Server) and follow the same scope and policy steps against it.

1.1 Note the Default Authorization Server's Issuer and Audience

  1. In the Okta admin consoleopen in new window, go to Security > API > Authorization Servers, and open the one named default.

  2. On its Settings tab, copy the Issuer:

    https://<your-okta-domain>/oauth2/default
    
  3. Note the Audience value already configured there (out of the box this is api://default, but your org may have changed it). Leave it as-is — you will point DAGC at whatever it currently is in Step 2.3, rather than changing it to match the protected MCP endpoint. Changing a shared default's Audience would affect every other app already relying on it.

    Okta — default Authorization Server Settings tab showing Issuer and Audience

1.2 Add a Custom Scope

  1. Still on the default Authorization Server, go to the Scopes tab and click Add Scope.

  2. Fill in:

    FieldValue
    Nameapi://default/access
    Display phraseAccess CRM MCP Gateway
    DescriptionAllows ChatGPT to access the CRM MCP Gateway on behalf of the signed-in user.
  3. Click Create.

    Okta — Scopes tab showing the api://default/access custom scope added to the default Authorization Server

1.3 Register the App Integration

This is the app ChatGPT actually signs users into.

  1. Go to Applications > Applications and click Create App Integration.

  2. Choose OIDC - OpenID Connect as the sign-in method and Native Application as the application type, then click Next.

    ChatGPT's custom connector form lets you register your own OAuth client and doesn't require a client secret — so it authenticates as a public client using authorization code + PKCE. Native Application is Okta's public-client integration type: it supports PKCE and lets you add an arbitrary redirect URI, unlike Web Application, which expects a client secret.

  3. Fill in:

    FieldValue
    App integration nameChatGPT CRM MCP Client
    Grant typeLeave the default Authorization Code checked, and also check Refresh Token
    Sign-in redirect URIsLeave the default placeholder for now
    Controlled accessAssign to the groups that should be able to use this connector, or Allow everyone in your organization to access

    Enable Refresh Token to avoid repeated logins

    Without the Refresh Token grant, ChatGPT has no way to renew the access token once it expires — the user has to manually reconnect the connector every time. Checking it lets ChatGPT silently obtain a new access token in the background, so the user stays connected across sessions.

    Redirect URI is unique per connector, not fixed

    ChatGPT doesn't use one shared redirect URI across all custom connectors. Each connector gets its own callback URL (e.g. https://chatgpt.com/connector/oauth/S2tqhGpwDpxd), generated when you configure OAuth for that connector in Step 3.1. You'll come back and replace the placeholder redirect URI with that connector-specific value once ChatGPT generates it.

    Okta — Create App Integration form for a Native Application

  4. Click Save. On the app's General tab, copy the Client ID — you'll need it in Step 3.

    Okta — App Integration General tab showing the Client ID

    Assignment is required

    Unlike an Entra ID single-tenant app, an Okta App Integration only lets in the users or groups you explicitly assign on its Assignments tab (unless you chose Allow everyone in your organization to access in the step above). If a user's sign-in fails with "You do not have access," check this app's assignments.

1.4 Restrict the Access Policy

The default Authorization Server ships with a Default Policy that usually grants "Any scopes" to "All clients." Don't skip this step: Datawiza checks a token's issuer, audience, and scope, but not which client requested it. If the Default Policy still grants api://default/access to all clients, any other app on default can get a token that passes those checks too.

Editing Default Policy won't fix this — it applies to All clients. Instead, create a separate policy assigned only to ChatGPT CRM MCP Client:

  1. Go to the Access Policies tab of the default Authorization Server and click Add New Access Policy.

  2. Set Assigned to to ChatGPT CRM MCP Client specifically — not All clients.

  3. Add a rule:

    FieldValue
    Rule NameChatGPT CRM MCP Access
    Grant type isAuthorization Code
    User isAny user assigned the app
    Scopes requestedThe following scopes: openid, profile, offline_access, and api://default/access
  4. Click Create Rule (or Save).

Step 2: Configure Datawiza Agent Gateway

2.1 Sign in and click Getting Started

Log into Datawiza Agent Gateway Console (DAGC)open in new window and click the Getting Started button on the home page.

Datawiza Agent Gateway Console home page with Getting Started button

2.2 Name your Deployment

The Getting Started wizard opens at Step 1 of 4 — Deployment Name.

  1. Enter a Name for the deployment (e.g., CRM MCP Gateway).
  2. Click Next.

Getting Started wizard Step 1 — enter a deployment name

2.3 Add a Service

Step 2 of 4 — Service defines the public-facing MCP endpoint that ChatGPT connects to.

FieldValue
NameCRM MCP Service
Base (Load Balancer) URLYour public gateway URL, e.g. https://crm-mcp.company.com
SSLEnable — check Enable SSL and use datawiza self-signed certificate
Listen Port443
Authentication MethodOkta Access Token
Issuerhttps://<your-okta-domain>/oauth2/default (from Step 1.1)
AudienceThe default Authorization Server's existing Audience value from Step 1.1 — typically api://default unless your org changed it
Authorization Serverhttps://<your-okta-domain>/oauth2/default — the same URL as Issuer

Click Next.

Authorization Server matches the Issuer here

For Okta, the token's iss claim and the metadata endpoint DAGC uses to fetch signing keys are the same URL, so Authorization Server repeats the Issuer value. (This differs from Entra ID, where the v1.0 issuer and the v2.0 metadata endpoint diverge.)

ChatGPT rejects self-signed certificates

The wizard only offers the Datawiza self-signed certificate, and ChatGPT rejects it. After deploying in Step 2.5, replace it with a trusted CA certificate — see Step 2.6.

Getting Started wizard Step 2 — Service form showing Name, Description, Base URL, SSL, and Listen Port fieldsGetting Started wizard Step 2 — Service form showing Okta Access Token authentication fields for Issuer, Audience, and Authorization Server

2.4 Add a Backend

Step 3 of 4 — Backend points the gateway at your existing internal MCP server.

FieldValue
NameInternal CRM MCP
TypeMCP
Backend Servershttp://internal-crm-mcp:3000
Auth typeNo Auth

Click Create.

Getting Started wizard Step 3 — configure the internal MCP server as the backend

2.5 Deploy the Gateway

Step 4 of 4 — Deploy shows your provisioning credentials and the startup commands.

  1. Note the Provisioning Key and Provisioning Secret shown at the top.

  2. Run the two commands on your gateway host:

    # Install Docker and pull the Datawiza Agent Gateway image
    curl https://datawiza.s3.us-west-2.amazonaws.com/datawiza-dag-env-prep.sh | sh
    
    # Start Datawiza Agent Gateway
    curl -s https://datawiza.s3.us-west-2.amazonaws.com/datawiza-dag-docker-compose-prep.sh \
      | bash -s -- -k <PROVISIONING_KEY> -s <PROVISIONING_SECRET> -p 443 \
      && sudo docker compose up -d
    
  3. Click Done.

Getting Started wizard Step 4 — provisioning keys and deploy commands

The gateway pulls its full configuration from DAGC automatically.

2.6 Replace the Self-Signed Certificate

The service is currently using the Datawiza self-signed certificate from Step 2.3. Before connecting ChatGPT, replace it with a certificate from a trusted CA by following SSL Certificates in Datawiza Agent Gateway: go to Services in DAGC, open this service's Advanced tab, click Edit, then Update Certificate to upload your PEM-format certificate and private key.

Step 3: Add the Protected MCP Endpoint to ChatGPT

ChatGPT's connector setup lets you register your own OAuth client and pass in the Okta App Integration's Client ID directly.

Developer mode may be required

Some ChatGPT plans and workspace configurations gate custom MCP connectors behind a Developer mode setting. If you don't see a way to create a custom connector, check your account or workspace settings for a Developer mode toggle — its exact location varies by plan and has changed over time, so check OpenAI's help centeropen in new window if it isn't where you expect.

ChatGPT desktop app

If you use the ChatGPT desktop app, complete this connector setup in the ChatGPT web version first — it isn't available from the desktop app's own settings.

3.1 Create the Connector

  1. Go to Apps in your ChatGPT workspace or account settings, and click Create.

  2. Fill in:

    FieldValue
    NameInternal CRM MCP
    ConnectionServer URL
    MCP Server URLhttps://crm-mcp.company.com/mcp
    AuthenticationOAuth
  3. Expand Advanced OAuth settings and set Registration method to User-Defined OAuth Client. This tells ChatGPT to use your own Okta App Integration instead of attempting Dynamic Client Registration (DCR) or a Client Identifier Metadata Document (CIMD) — Datawiza Agent Gateway's protected endpoint doesn't advertise support for either.

  4. Copy the Callback URL shown in this panel (e.g. https://chatgpt.com/connector/oauth/S2tqhGpwDpxd) — ChatGPT generates it specifically for this connector.

    ChatGPT — Create connector form with Advanced OAuth settings expanded, showing the generated Callback URL

  5. Register that callback URL in Okta before continuing:

    1. In the Okta admin console, open ChatGPT CRM MCP Client > General > Edit.
    2. Under Sign-in redirect URIs, replace the placeholder with the callback URL and click Save.
  6. Back in ChatGPT, finish the Client registration panel:

    FieldValue
    OAuth Client IDThe Client ID of ChatGPT CRM MCP Client from Step 1.3
    OAuth Client SecretLeave blank — this is a public client
  7. Click Create.

On a ChatGPT Business or Enterprise workspace, a workspace admin also needs to publish the connector — from its detail page in the Apps admin console — before it's available to use. Publishing rolls it out to the whole organization, so individual users don't need to configure it themselves.

Step 4: Verify Unauthenticated Access Is Blocked

Before testing with ChatGPT, confirm the gateway is rejecting unauthenticated requests:

curl -ik https://crm-mcp.company.com/mcp

Expected response:

HTTP/1.1 401 Unauthorized

This confirms that Datawiza is intercepting traffic and no unauthenticated request can reach the backend MCP server.

Step 5: Sign In with Okta

When you finish creating the connector, ChatGPT shows its detail page with a Connect button. Clicking it starts the Okta sign-in flow using the Client ID you entered. Datawiza validates the resulting access token on every request.

  1. Click Connect on the connector's detail page.

    ChatGPT connector detail page showing the Connect button

  2. ChatGPT opens a browser popup prompting you to authenticate.

  3. The popup redirects to the Okta login page. Sign in with your enterprise account.

    Okta login page

  4. After a successful sign-in, Okta redirects back to the connector's callback URL you registered in Step 3.1 (e.g. https://chatgpt.com/connector/oauth/S2tqhGpwDpxd). ChatGPT stores the access token and attaches it as a bearer token to each MCP request. Datawiza validates the token — checking the issuer, the MCP endpoint audience, and the api://default/access scope — before forwarding the request to the backend.

  5. ChatGPT replaces the Connect button with Start chat, and its tools become available to attach in a chat.

    ChatGPT showing the Start chat button after a successful sign-in

A successful sign-in doesn't guarantee the right scope

Datawiza rejects any token that lacks the api://default/access scope, even when the sign-in itself succeeded. If tool calls fail with 401 Unauthorized right after connecting, the token Okta issued likely doesn't carry that scope — check that the access policy rule from Step 1.4 actually grants it to ChatGPT CRM MCP Client.

Once connected, ChatGPT can call MCP tools for the duration of the session. An expired or missing token returns 401 Unauthorized and triggers a new login prompt the next time the connector is used.

Step 6: Call MCP Tools from ChatGPT

With the MCP server connected, attach it to a chat and test tools to confirm end-to-end authentication is working.

  1. Start a new chat in ChatGPT.
  2. Click the + icon next to the message box, select More, and choose the Internal CRM MCP connector.

Get a customer profile

In ChatGPT, type:

Use the Internal CRM MCP connector to get the profile for customer c001.

ChatGPT calls get_customer_profile and shows the result.

ChatGPT calling get_customer_profile and displaying the result

List customer orders

In ChatGPT, type:

List recent orders for c001.

ChatGPT calls list_customer_orders and displays the order history.

ChatGPT calling list_customer_orders and displaying the result

Step 7: Verify Datawiza Logs and Audit Records

In DAGC, open the logs for your deployment and confirm the following events appear:

  • User login event with the authenticated user's email
  • Okta authentication success
  • Request allowed or denied based on policy
  • Request forwarded to the backend MCP server
  • MCP tool call recorded with user context

This confirms that Datawiza is acting as the authentication, identity, and policy enforcement layer for all ChatGPT-to-MCP traffic.

Summary

Your MCP server stays simple — it exposes tools for ChatGPT without implementing enterprise OAuth. Datawiza Agent Gateway becomes the front door: it handles Okta login, validates tokens, enforces access policy, and forwards only authenticated traffic to the backend.

This separation of concerns means MCP server developers can focus on building useful tools, while identity and access control remain owned by the teams responsible for them. The same pattern applies to any internal MCP server — CRM, HR, finance, ticketing, or internal APIs — without changing a line of server code.

ChatGPT users get a seamless experience: they authenticate once with their enterprise Okta credentials, and all MCP tools become available for the session. Unauthenticated or unauthorized requests never reach the backend.