# Start authorization

Source: https://docs.musicnerd.net/api-reference/oauth/authorize

Start authorization

## GET /api/oauth/auth

Full OpenAPI specification: https://docs.musicnerd.net/spec/oauth.json

## Authentication

This operation's specification permits a request without authentication.

[Authentication guide](https://docs.musicnerd.net/authentication)

## Operation and referenced schemas

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Music Nerd API: OAuth",
    "version": "1.0.0",
    "description": "How agents connect to the MCP server with OAuth: the discovery documents an MCP client reads, and the member's list of connected agents."
  },
  "servers": [
    {
      "url": "https://api.musicnerd.net",
      "description": "Production"
    },
    {
      "url": "https://musicnerd-api-staging.vercel.app",
      "description": "Staging (staging database)"
    }
  ],
  "paths": {
    "/api/oauth/auth": {
      "get": {
        "summary": "Start authorization",
        "operationId": "authorizeOAuthClient",
        "security": [],
        "description": "Where an MCP client sends the user's browser to connect. A valid request redirects to the Music Nerd page where the user signs in and approves the agent; an invalid one redirects back to the client with `error` and `state`.",
        "parameters": [
          {
            "name": "response_type",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "code"
              ]
            },
            "example": "code",
            "description": "Always `code`."
          },
          {
            "name": "client_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "2f6c1d0e-8a4b-4c47-9a51-3e0f7b9d2c18",
            "description": "The `client_id` from registration."
          },
          {
            "name": "redirect_uri",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "http://127.0.0.1:33418/callback",
            "description": "One of the client's registered redirect URIs, exactly."
          },
          {
            "name": "code_challenge",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM",
            "description": "The PKCE challenge: base64url SHA-256 of the code verifier."
          },
          {
            "name": "code_challenge_method",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "S256"
              ]
            },
            "example": "S256",
            "description": "Always `S256`."
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "af0ifjsldkj",
            "description": "Returned unchanged to the client."
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "mcp:tools",
            "description": "`mcp:tools`, the only scope. Optional."
          },
          {
            "name": "resource",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "https://api.musicnerd.net/mcp",
            "description": "`https://api.musicnerd.net/mcp`, if sent."
          }
        ],
        "responses": {
          "302": {
            "description": "To the Music Nerd sign-in page with the same query, or back to `redirect_uri` with `error` and `state` when the request is invalid.",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri"
                },
                "description": "The sign-in page, or the client's redirect URI with the error."
              }
            }
          },
          "400": {
            "description": "Unknown `client_id`, or a `redirect_uri` the client didn't register. Nothing is redirected.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "invalid_request",
                  "error_description": "Unknown client or redirect_uri"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "OAuthError": {
        "type": "object",
        "description": "The standard OAuth error shape (RFC 6749), used by registration, authorization and the token endpoint instead of `{status, error}`.",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "An OAuth error code, like `invalid_grant`."
          },
          "error_description": {
            "type": "string"
          }
        }
      }
    }
  }
}
```
