MCPcopy
hub / github.com/github/github-mcp-server / randomState

Function randomState

internal/oauth/oauth.go:96–102  ·  view source on GitHub ↗

randomState returns a cryptographically random URL-safe string used as the OAuth state parameter (CSRF protection) and elicitation IDs.

()

Source from the content-addressed store, hash-verified

94// randomState returns a cryptographically random URL-safe string used as the
95// OAuth state parameter (CSRF protection) and elicitation IDs.
96func randomState() (string, error) {
97 b := make([]byte, 16)
98 if _, err := rand.Read(b); err != nil {
99 return "", fmt.Errorf("generating random state: %w", err)
100 }
101 return base64.RawURLEncoding.EncodeToString(b), nil
102}

Callers 2

TestRandomStateFunction · 0.85
beginPKCEMethod · 0.85

Calls 1

ReadMethod · 0.80

Tested by 1

TestRandomStateFunction · 0.68