MCPcopy Index your code
hub / github.com/modelcontextprotocol/registry / GetToken

Method GetToken

cmd/publisher/auth/common.go:67–86  ·  view source on GitHub ↗

GetToken retrieves the registry JWT token using cryptographic authentication

(ctx context.Context)

Source from the content-addressed store, hash-verified

65
66// GetToken retrieves the registry JWT token using cryptographic authentication
67func (c *CryptoProvider) GetToken(ctx context.Context) (string, error) {
68 if c.domain == "" {
69 return "", fmt.Errorf("%s domain is required", c.authMethod)
70 }
71
72 // Generate current timestamp
73 timestamp, signedTimestamp, err := c.signer.GetSignedTimestamp(ctx)
74 if err != nil {
75 return "", fmt.Errorf("failed to sign timestamp: %w", err)
76 }
77 signedTimestampHex := hex.EncodeToString(signedTimestamp)
78
79 // Exchange signature for registry token
80 registryToken, err := c.exchangeTokenForRegistry(ctx, c.domain, *timestamp, signedTimestampHex)
81 if err != nil {
82 return "", fmt.Errorf("failed to exchange %s signature: %w", c.authMethod, err)
83 }
84
85 return registryToken, nil
86}
87
88type InProcessSigner struct {
89 privateKey []byte

Callers

nothing calls this directly

Calls 2

GetSignedTimestampMethod · 0.65

Tested by

no test coverage detected