diff --git a/src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj b/src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj
index 34d5e9c1868..032053228f2 100644
--- a/src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj
+++ b/src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj
@@ -4,22 +4,22 @@
netstandard2.0;net6.0;net472
Microsoft.Graph.PowerShell.Authentication.Core
2.0.0
- preview5
+ preview7
true
true
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
diff --git a/src/Authentication/Authentication.Core/Utilities/JwtHelpers.cs b/src/Authentication/Authentication.Core/Utilities/JwtHelpers.cs
index f7747db81c8..be76c470307 100644
--- a/src/Authentication/Authentication.Core/Utilities/JwtHelpers.cs
+++ b/src/Authentication/Authentication.Core/Utilities/JwtHelpers.cs
@@ -5,10 +5,10 @@
using Microsoft.Graph.PowerShell.Authentication.Core.Models;
using Microsoft.Graph.PowerShell.Authentication.Models;
using Microsoft.Identity.Client;
-using Newtonsoft.Json;
using System;
using System.Globalization;
using System.Text;
+using System.Text.Json;
namespace Microsoft.Graph.PowerShell.Authentication.Core.Utilities
{
@@ -64,7 +64,7 @@ internal static T DecodeToObject(string jwtString)
var decodedJWT = DecodeJWT(jwtString);
if (string.IsNullOrWhiteSpace(decodedJWT?.Payload))
return default;
- return JsonConvert.DeserializeObject(decodedJWT.Payload);
+ return JsonSerializer.Deserialize(decodedJWT.Payload);
}
catch (Exception ex)
{
diff --git a/src/Authentication/Authentication/Cmdlets/ConnectMgGraph.cs b/src/Authentication/Authentication/Cmdlets/ConnectMgGraph.cs
index 7221842ef77..ae6442d4c54 100644
--- a/src/Authentication/Authentication/Cmdlets/ConnectMgGraph.cs
+++ b/src/Authentication/Authentication/Cmdlets/ConnectMgGraph.cs
@@ -6,6 +6,7 @@
using Microsoft.Graph.PowerShell.Authentication.Core.Extensions;
using Microsoft.Graph.PowerShell.Authentication.Core.TokenCache;
using Microsoft.Graph.PowerShell.Authentication.Core.Utilities;
+using Microsoft.Graph.PowerShell.Authentication.Extensions;
using Microsoft.Graph.PowerShell.Authentication.Helpers;
using Microsoft.Graph.PowerShell.Authentication.Interfaces;
using Microsoft.Graph.PowerShell.Authentication.Models;
@@ -15,6 +16,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
+using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text;
@@ -177,8 +179,16 @@ private async Task ProcessRecordAsync()
authContext.AuthType = AuthenticationType.Delegated;
string[] processedScopes = ProcessScopes(Scopes);
authContext.Scopes = !processedScopes.Any() ? new[] { "User.Read" } : processedScopes;
- // Default to CurrentUser but allow the customer to change this via `-ContextScope`.
- authContext.ContextScope = this.IsParameterBound(nameof(ContextScope)) ? ContextScope : ContextScope.CurrentUser;
+ if (RuntimeInformation.OSDescription.ContainsValue("WSL", StringComparison.InvariantCulture))
+ {
+ // Use process scope when on WSL. WSL does not have secret service that's used to cache tokens on Linux, see https://github.com/microsoft/WSL/issues/4254.
+ authContext.ContextScope = ContextScope.Process;
+ }
+ else
+ {
+ // Default to CurrentUser but allow the customer to change this via `-ContextScope`.
+ authContext.ContextScope = this.IsParameterBound(nameof(ContextScope)) ? ContextScope : ContextScope.CurrentUser;
+ }
authContext.TokenCredentialType = UseDeviceCode ? TokenCredentialType.DeviceCode : TokenCredentialType.InteractiveBrowser;
}
break;
diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj b/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj
index 2afdbb09119..a856ecb1eab 100644
--- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj
+++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj
@@ -11,7 +11,7 @@
Microsoft.Graph.Authentication.nuspec
© Microsoft Corporation. All rights reserved.
2.0.0
- preview5
+ preview7
true
diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec b/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec
index 83944f0aca2..81b6a386f5c 100644
--- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec
+++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec
@@ -1,7 +1,7 @@
- 2.0.0-preview5
+ 2.0.0-preview7
Microsoft.Graph.Authentication
Microsoft Graph PowerShell authentication module
Microsoft
@@ -25,6 +25,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -35,23 +50,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1
index d0a1379d782..b978cbf4402 100644
--- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1
+++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1
@@ -3,7 +3,7 @@
#
# Generated by: Microsoft
#
-# Generated on: 3/10/2023
+# Generated on: 3/22/2023
#
@{
@@ -114,7 +114,7 @@ PrivateData = @{
ReleaseNotes = 'See https://aka.ms/GraphPowerShell-Release.'
# Prerelease string of this module
- Prerelease = 'preview5'
+ Prerelease = 'preview7'
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false
diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psm1 b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psm1
index a50eca13679..ecce2d0516a 100644
--- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psm1
+++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psm1
@@ -17,7 +17,7 @@ if (Test-Path -Path "$PSScriptRoot\StartupScripts" -ErrorAction Ignore)
Export-ModuleMember -Cmdlet (Get-ModuleCmdlet -ModulePath $ModulePath) -Alias (Get-ModuleCmdlet -ModulePath $ModulePath -AsAlias)
$DependencyPath = (Join-Path $PSScriptRoot -ChildPath "Dependencies")
-if (Test-Path $DependencyPath -ErrorAction Ignore)
+if ((Test-Path $DependencyPath -ErrorAction Ignore) -and ($PSEdition -eq "Desktop"))
{
try
{