randomState returns a cryptographically random URL-safe string used as the OAuth state parameter (CSRF protection) and elicitation IDs.
()
| 94 | // randomState returns a cryptographically random URL-safe string used as the |
| 95 | // OAuth state parameter (CSRF protection) and elicitation IDs. |
| 96 | func 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 | } |