Skip to content

Commit 9a4cea0

Browse files
committed
Update BasicOAuthAuthorizationProvider.cs
1 parent 43eb6ff commit 9a4cea0

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

samples/ProtectedMCPClient/BasicOAuthAuthorizationProvider.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ namespace ProtectedMCPClient;
1616
/// </summary>
1717
public class BasicOAuthAuthorizationProvider : ITokenProvider
1818
{
19+
/// <summary>
20+
/// The Bearer authentication scheme.
21+
/// </summary>
22+
private const string BearerScheme = "Bearer";
23+
1924
private readonly Uri _serverUrl;
2025
private readonly Uri _redirectUri;
2126
private readonly List<string> _scopes;
@@ -63,13 +68,13 @@ public BasicOAuthAuthorizationProvider(
6368
}
6469

6570
/// <inheritdoc />
66-
public IEnumerable<string> SupportedSchemes => new[] { "Bearer" };
71+
public IEnumerable<string> SupportedSchemes => new[] { BearerScheme };
6772

6873
/// <inheritdoc />
6974
public Task<string?> GetCredentialAsync(string scheme, Uri resourceUri, CancellationToken cancellationToken = default)
7075
{
7176
// This provider only supports Bearer tokens
72-
if (scheme != "Bearer")
77+
if (scheme != BearerScheme)
7378
{
7479
return Task.FromResult<string?>(null);
7580
}
@@ -84,7 +89,7 @@ public async Task<McpUnauthorizedResponseResult> HandleUnauthorizedResponseAsync
8489
CancellationToken cancellationToken = default)
8590
{
8691
// This provider only supports Bearer scheme
87-
if (scheme != "Bearer")
92+
if (scheme != BearerScheme)
8893
{
8994
return new McpUnauthorizedResponseResult(false, null);
9095
}
@@ -111,7 +116,7 @@ public async Task<McpUnauthorizedResponseResult> HandleUnauthorizedResponseAsync
111116
if (token != null)
112117
{
113118
_token = token;
114-
return new McpUnauthorizedResponseResult(true, "Bearer");
119+
return new McpUnauthorizedResponseResult(true, BearerScheme);
115120
}
116121
}
117122
}

0 commit comments

Comments
 (0)