Skip to content

Commit 9a7913e

Browse files
committed
Merge branch 'ramsess/fix-DeviceCodeAuthFlow' of https://github.com/microsoftgraph/msgraph-sdk-powershell into ramsess/fix-DeviceCodeAuthFlow
2 parents e432ef7 + 0c22695 commit 9a7913e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Authentication/Authentication.Core/Utilities/AuthenticationHelpers.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ private static async Task<DeviceCodeCredential> GetDeviceCodeCredentialAsync(IAu
167167
GraphSession.Instance.OutputWriter.WriteObject(code.Message);
168168
return Task.CompletedTask;
169169
}
170-
catch
170+
catch (InvalidOperationException)
171+
{
172+
// Fall through to console output if OutputWriter is unavailable.
173+
}
174+
catch (ObjectDisposedException)
171175
{
172176
// Fall through to console output if OutputWriter is unavailable.
173177
}

src/Authentication/Authentication.Test/Helpers/AuthenticationHelpersTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,8 @@ public async Task ShouldUseWamWhenNullWithCustomClientIdAsync()
533533
// reset static instance.
534534
GraphSession.Reset();
535535
}
536-
536+
537+
537538
[Fact]
538539
public async Task SignInAsync_ShouldCallGetTokenAsync_WithCaeEnabledAsync()
539540
{
@@ -617,10 +618,12 @@ await AuthenticationHelpers.SignInAsync(
617618
_ = await authProvider.GetAuthorizationTokenAsync(
618619
new Uri("https://graph.microsoft.com/v1.0/me"));
619620

620-
// Assert: both paths must use isCaeEnabled: true so that MSAL serves
621621
// the cached token silently during API calls.
622+
Assert.NotNull(signInContext);
622623
Assert.True(signInContext.IsCaeEnabled,
623624
"SignInAsync must pass isCaeEnabled: true to GetTokenAsync.");
625+
Assert.NotNull(providerContext);
626+
"SignInAsync must pass isCaeEnabled: true to GetTokenAsync.");
624627
Assert.True(providerContext.IsCaeEnabled,
625628
"AzureIdentityAccessTokenProvider must forward isCaeEnabled: true.");
626629

0 commit comments

Comments
 (0)