oauth_resource causes duplicate resource parameters in MCP OAuth authorization request
What version of the Codex App are you using (From “About Codex” dialog)?
Version 26.611.62324
What subscription do you have?
ChatGPT Business (organization-managed account)
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
What issue are you seeing?
Summary
I'm trying to connect a Streamable HTTP MCP server that requires OAuth authentication from the Codex app.
During the OAuth flow, the MCP client needs to send a request to the IdP's /authorize endpoint. This request includes a resource parameter.
For our IdP (Microsoft Entra ID), the required value of resource is not the MCP server URL. Instead, it must be a value in the format:
api://<client-id>
Codex provides an oauth_resource configuration option for MCP servers, so I assume this is the intended way to specify a custom resource value.
Actual Behavior
When oauth_resource is configured, the authorization request generated by Codex contains the resource parameter twice.
For example:
https://login.microsoftonline.com/.../oauth2/v2.0/authorize
?client_id=...
&response_type=code
&redirect_uri=...
&scope=...
&resource=https://mcp.example.com
&resource=api://<client-id>
It appears that Codex:
- Automatically derives a
resourcevalue from the MCP server URL, and - Adds the value specified in
oauth_resource
As a result, the request contains duplicate resource parameters, and Microsoft Entra ID rejects the request.
What steps can reproduce the bug?
- Configure a Streamable HTTP MCP server that uses OAuth authentication with Microsoft Entra ID.
- Set oauth_resource in the MCP server configuration to a value such as:
api://<client-id>
- Start the OAuth login flow from the Codex app.
- Inspect the request sent to the IdP's /authorize endpoint.
- Observe that the authorization request contains two resource parameters:
- One derived from the MCP server URL.
- One from the configured oauth_resource value.
- Observe that Microsoft Entra ID rejects the authorization request because of the duplicate resource parameters.
What is the expected behavior?
When oauth_resource is specified, Codex should use that value as the sole resource parameter and should not automatically add a second value derived from the MCP server URL.
Expected request:
&resource=api://<client-id>
Additional information
I found previous discussions related to support for the OAuth resource parameter (RFC 8707), and oauth_resource appears to have been introduced for this purpose.
However, the issue I'm seeing is not that resource cannot be specified, but that specifying oauth_resource results in duplicate resource parameters being included in the authorization request.
2 Comments
I am having the same issue - Codex seems to insist that one resource with the URL of the MCP server has to be sent regardless. This is likely because of the https://datatracker.ietf.org/doc/rfc9728/ spec
Either this is a bug or they need to clarify that such parameter is only for "additional" resources in the URL.
Hopefully they will address/clarify it soon
Additional repro from Codex CLI
0.146.0on macOS, with Microsoft Entra / Power BI remote MCP impact.I think the root problem is slightly broader than duplicate
oauth_resource: Codex appears to ignore theresourcevalue advertised by OAuth Protected Resource Metadata and still derives the OAuthresourceparameter from the MCP server URL.Minimal local repro:
http://127.0.0.1:9876/mcp.GET /mcpreturn401with:WWW-Authenticate: Bearer resource_metadata="http://127.0.0.1:9876/.well-known/oauth-protected-resource"GET /.well-known/oauth-protected-resourcereturn:``
json
``{
"resource": "https://analysis.windows.net/powerbi/api",
"authorization_servers": [
"https://login.microsoftonline.com/<tenant-id>/v2.0"
],
"bearer_methods_supported": ["header"],
"scopes_supported": [
"https://analysis.windows.net/powerbi/api/Dataset.Read.All",
"https://analysis.windows.net/powerbi/api/MLModel.Execute.All",
"https://analysis.windows.net/powerbi/api/Workspace.Read.All"
]
}
``
sh
``codex mcp add codex-resource-metadata-test --url http://127.0.0.1:9876/mcp --oauth-client-id <redacted-public-client-id>
codex mcp login codex-resource-metadata-test
Observed authorization URL:
Expected authorization URL should use the protected-resource metadata resource:
Real-world impact:
The official Microsoft Power BI remote MCP endpoint is:
Power BI delegated scopes are under:
Codex builds an Entra authorize/token flow with a
resourcederived from the MCP URL instead of the protected resource / Power BI API resource. Microsoft Entra rejects the flow with:This is not an app registration or tenant consent problem. The same Power BI MCP endpoint works when called with a bearer token acquired separately for either
https://api.fabric.microsoft.comorhttps://analysis.windows.net/powerbi/api.Requested behavior:
resource, Codex should use that value as the OAuth resource indicator instead of deriving it from the MCP endpoint URL.oauth_resourceis configured, it should replace the derived/metadata resource, not append an additionalresourceparameter.