We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7c33562 commit 8d4c0c4Copy full SHA for 8d4c0c4
src/ModelContextProtocol/Auth/OAuthService.cs
@@ -363,11 +363,12 @@ private string GenerateRandomString(int length)
363
var bytes = new byte[length];
364
using var rng = RandomNumberGenerator.Create();
365
rng.GetBytes(bytes);
366
- return Convert.ToBase64String(bytes)
367
- .Replace('+', '-')
368
- .Replace('/', '_')
369
- .Replace("=", "")
370
- .Substring(0, length);
+
+ // Use the optimized Base64UrlHelpers for encoding
+ string base64Url = Base64UrlHelpers.Encode(bytes);
+ // Ensure we return exactly the requested length
371
+ return base64Url.Substring(0, Math.Min(base64Url.Length, length));
372
}
373
374
// This method would be used in a real implementation after receiving the authorization code
0 commit comments