Skip to content

OAuth invalid_target error — PRM resource mismatch between path-specific endpoint and authorization server #836

Closed

Description

@natti1399

Problem

Claude Code (v2.1.76) cannot authenticate with the Sentry MCP server. The OAuth flow fails with:

invalid_target: The resource parameter does not match this authorization server

Root Cause

The path-specific Protected Resource Metadata (PRM) endpoint returns a resource value that the authorization server does not accept.

Root PRM (/.well-known/oauth-protected-resource):

{
  "resource": "https://mcp.sentry.dev",
  "authorization_servers": ["https://mcp.sentry.dev"]
}

Path-specific PRM (/.well-known/oauth-protected-resource/mcp):

{
  "resource": "https://mcp.sentry.dev/mcp",
  "authorization_servers": ["https://mcp.sentry.dev"]
}

Per RFC 9728, Claude Code discovers the path-specific PRM (since the MCP URL is https://mcp.sentry.dev/mcp) and sends resource=https://mcp.sentry.dev/mcp in the OAuth authorization request.

However, the authorization server only recognizes https://mcp.sentry.dev as a valid resource, so it rejects with invalid_target.

Steps to Reproduce

  1. Add Sentry MCP to Claude Code config:
    {
      "mcpServers": {
        "sentry": {
          "type": "http",
          "url": "https://mcp.sentry.dev/mcp"
        }
      }
    }
  2. Start Claude Code, attempt to authenticate with Sentry
  3. Browser opens, immediately shows: "Authentication Error — invalid_target: The resource parameter does not match this authorization server"

Expected Behavior

Either:

  • The path-specific PRM at /.well-known/oauth-protected-resource/mcp should return resource: "https://mcp.sentry.dev" (matching what the AS accepts), OR
  • The authorization server should accept https://mcp.sentry.dev/mcp as a valid resource

Environment

  • Claude Code 2.1.76 on macOS
  • MCP URL: https://mcp.sentry.dev/mcp

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions