MCPcopy Create free account
hub / github.com/bytebase/bytebase / Validate

Function Validate

backend/plugin/webhook/teams/app.go:603–622  ·  view source on GitHub ↗

Validate validates the Teams configuration by attempting to get a token and look up a user.

(ctx context.Context, tenantID, clientID, clientSecret, email string)

Source from the content-addressed store, hash-verified

601
602// Validate validates the Teams configuration by attempting to get a token and look up a user.
603func Validate(ctx context.Context, tenantID, clientID, clientSecret, email string) error {
604 // Trim whitespace from all inputs to prevent copy-paste issues.
605 tenantID = strings.TrimSpace(tenantID)
606 clientID = strings.TrimSpace(clientID)
607 clientSecret = strings.TrimSpace(clientSecret)
608 email = strings.TrimSpace(email)
609
610 p := newProvider(tenantID, clientID, clientSecret)
611
612 if err := p.refreshGraphToken(ctx); err != nil {
613 return errors.Wrapf(err, "failed to get Graph API token")
614 }
615
616 _, err := p.getIDByEmail(ctx, []string{email})
617 if err != nil {
618 return errors.Wrapf(err, "failed to look up user %s", email)
619 }
620
621 return nil
622}

Callers 1

UpdateSettingMethod · 0.92

Calls 3

refreshGraphTokenMethod · 0.80
newProviderFunction · 0.70
getIDByEmailMethod · 0.45

Tested by

no test coverage detected