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

Method Validate

oauthex/client.go:37–57  ·  view source on GitHub ↗

Validate checks that the ClientCredentials are properly configured. It ensures that: - ClientID is not empty. - At most one authentication method is configured. - If ClientSecretAuth is set, ClientSecret is not empty.

()

Source from the content-addressed store, hash-verified

35// - At most one authentication method is configured.
36// - If ClientSecretAuth is set, ClientSecret is not empty.
37func (c *ClientCredentials) Validate() error {
38 if c.ClientID == "" {
39 return errors.New("ClientID is required")
40 }
41
42 // Count how many auth methods are configured.
43 authMethodCount := 0
44 if c.ClientSecretAuth != nil {
45 authMethodCount++
46 if c.ClientSecretAuth.ClientSecret == "" {
47 return errors.New("ClientSecret is required when using ClientSecretAuth")
48 }
49 }
50
51 // Allow zero auth methods (public client) or exactly one auth method.
52 if authMethodCount > 1 {
53 return errors.New("only one client authentication method can be configured")
54 }
55
56 return nil
57}

Callers 9

ExchangeTokenFunction · 0.80
NewEnterpriseHandlerFunction · 0.80
ElicitMethod · 0.80
applySchemaFunction · 0.80
elicitMethod · 0.80
unmarshalAndValidateFunction · 0.80

Calls

no outgoing calls

Tested by 1