Exception: MCP::Server::OAuth::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/mcp/server/oauth/errors.rb

Overview

Error hierarchy for the OAuth 2.1 resource-server role. Each error carries the RFC 6750 Section 3.1 registered error code that Challenge places in the WWW-Authenticate response header. https://www.rfc-editor.org/rfc/rfc6750#section-3.1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, error_code: "invalid_token") ⇒ Error

error_code defaults to the code a token rejection carries, so a custom verifier can subclass this and raise MyError, "..." without knowing about the keyword. Authenticator#challenge_response answers any such error with 401 invalid_token, which is what the default names; without a default, the missing keyword would raise ArgumentError inside verify and surface as HTTP 500 instead.



16
17
18
19
# File 'lib/mcp/server/oauth/errors.rb', line 16

def initialize(message = nil, error_code: "invalid_token")
  super(message)
  @error_code = error_code
end

Instance Attribute Details

#error_code ⇒ Object (readonly)

Returns the value of attribute error_code.



10
11
12
# File 'lib/mcp/server/oauth/errors.rb', line 10

def error_code
  @error_code
end