Skip to content

Commit 4f9f9c1

Browse files
davidortinauCopilot
andcommitted
fix: AuthenticatedHttpMessageHandler tolerates missing AzureAd:Scopes
In the WebApp, this handler is registered but unused (the WebApp has its own OIDC-based AuthenticatedApiDelegatingHandler). Previously it threw on construction if AzureAd:Scopes was missing. Now it defaults to empty scopes and short-circuits SendAsync — a no-op passthrough. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4d32c64 commit 4f9f9c1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/SentenceStudio.AppLib/Services/AuthenticatedHttpMessageHandler.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ public AuthenticatedHttpMessageHandler(
2828
_logger = logger;
2929

3030
_defaultScopes = configuration.GetSection("AzureAd:Scopes").Get<string[]>()
31-
?? throw new InvalidOperationException(
32-
"AzureAd:Scopes must be configured.");
31+
?? Array.Empty<string>();
3332
}
3433

3534
protected override async Task<HttpResponseMessage> SendAsync(
3635
HttpRequestMessage request, CancellationToken cancellationToken)
3736
{
37+
if (_defaultScopes.Length == 0)
38+
return await base.SendAsync(request, cancellationToken);
39+
3840
try
3941
{
4042
var token = await _authService.GetAccessTokenAsync(_defaultScopes);

0 commit comments

Comments
 (0)