MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / handleProtectedResourceMetadata

Method handleProtectedResourceMetadata

oauthex/oauthex_test.go:81–97  ·  view source on GitHub ↗

handleProtectedResourceMetadata serves the OAuth 2.0 Protected Resource Metadata document, as defined in RFC 9728.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

79// handleProtectedResourceMetadata serves the OAuth 2.0 Protected Resource Metadata document,
80// as defined in RFC 9728.
81func (s *state) handleProtectedResourceMetadata(w http.ResponseWriter, r *http.Request) {
82 // Construct the authorization server issuer URL dynamically.
83 authServerIssuer := getBaseURL(r)
84
85 metadata := ProtectedResourceMetadata{
86 ScopesSupported: []string{"openid", "profile", "email"},
87 AuthorizationServers: []string{authServerIssuer},
88 }
89 var buf bytes.Buffer
90 if err := json.NewEncoder(&buf).Encode(metadata); err != nil {
91 http.Error(w, err.Error(), http.StatusInternalServerError)
92 return
93 }
94 w.Header().Set("Content-Type", "application/json")
95 w.WriteHeader(http.StatusOK)
96 w.Write(buf.Bytes())
97}
98
99func (s *state) handleServerMetadata(w http.ResponseWriter, r *http.Request) {
100 issuer := getBaseURL(r)

Callers

nothing calls this directly

Calls 4

getBaseURLFunction · 0.85
BytesMethod · 0.80
WriteMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected