Skip to content

OAuth with GoogleProvider fails when connecting MCP server to ChatGPT or Claude connectors because of scopes #1794

Description

@alexeymaelys

Description

The MCP server is set up to use GoogleProvider (OAuthProxy). I'm connecting using a ChatGPT Custom Connector (also tried Claude - same result).

It's set up Auth to ask for scopes "openid", "https://www.googleapis.com/auth/userinfo.email" on Auth creation, but when inspected with the DevTools, server doesn't set scope in the redirect request. ChatGPT answers with "invalid token".

Logs that i see on MCP server:

"GET /.well-known/oauth-authorization-server HTTP/1.1" 200 OK
"POST /register HTTP/1.1" 201 Created
"GET /authorize?response_type=code&client_id=<redacted (uuid)>&redirect_uri=https%3A%2F%2Fchatgpt.com%2Fconnector_platform_oauth_redirect&state=oauth_s_<redacted (key)>&**scope=**&code_challenge=<redacted (key)>&code_challenge_method=S256 HTTP/1.1" 302 Found

On the browser I see additional response:
https://chatgpt.com/connector_platform_oauth_redirect?error=invalid_scope&error_description=Client+was+not+registered+with+scope+&state=oauth_s_<redacted (key)>

The same MCP server I was able to connect like this without OAuth at all - it functioned properly.

Thank you! Be sure to ask other details if needed.

Example Code

def create_server():
    """Create and configure the MCP server."""

    auth_provider = GoogleProvider(
    client_id=client_id,  # Your Google OAuth Client ID
    client_secret=client_secret,      
    base_url=base_url,     
    redirect_path="/auth/callback",
    required_scopes=["openid", "https://www.googleapis.com/auth/userinfo.email"]                                  
    )
    mcp = FastMCP(name="Sample MCP Server", instructions=server_instructions, auth=auth_provider)

    return mcp
    

def main():
    """Main function to start the MCP server."""

    server = create_server()
    logger.info("Starting MCP server on 0.0.0.0:8000")
    logger.info("Server will be accessible via HTTP transport")

    server.run(transport="http", host="0.0.0.0", port=8000)

Version Information

2.12.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    authRelated to authentication (Bearer, JWT, OAuth, WorkOS) for client or server.bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.serverRelated to FastMCP server implementation or server-side functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions