Protected resource metadatav3.16+

Use the OpenID Connect plugin to advertise this API as an OAuth 2.0 protected resource, as defined by RFC 9728. This lets OAuth and OpenID Connect clients, including MCP (Model Context Protocol) clients, automatically discover which authorization server protects this API and which scopes it supports.

When configured, the OIDC plugin serves a metadata document at a well-known URI derived from resource, and adds a resource_metadata attribute (and a scope attribute, if scopes_supported is set) to the WWW-Authenticate header on 401 Unauthorized responses.

This example pairs protected resource metadata with JWT access token (bearer) authentication. A client that presents no token, or an invalid one, receives a 401 response whose WWW-Authenticate header points it to the metadata document.

For more detail, see Protected resource metadata.

Prerequisites

  • An identity provider that issues bearer tokens for this API.

Environment variables

  • ISSUER: The issuer authentication URL for the authorization server that protects this API. For example, if you’re using Keycloak as your IdP, the issuer URL looks like this: http://localhost:8080/realms/example-realm.

  • RESOURCE: The URI of this protected resource, for example https://api.example.com/mcp. This is also used to derive the well-known metadata endpoint path.

  • SCOPE: A scope supported by this protected resource, for example mcp:read.

Set up the plugin

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!