From e22d625b6d80849e21dc267a8636088e5e3a3c1d Mon Sep 17 00:00:00 2001 From: Steffen Kampmann Date: Wed, 29 Nov 2023 20:38:44 +0100 Subject: [PATCH] moved to azure.identity --- src/PsSqlClient/ConnectInstanceCommand.cs | 17 ++++++++++------- src/PsSqlClient/PsSqlClient.csproj | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/PsSqlClient/ConnectInstanceCommand.cs b/src/PsSqlClient/ConnectInstanceCommand.cs index 47ea41d..d4f7ac9 100644 --- a/src/PsSqlClient/ConnectInstanceCommand.cs +++ b/src/PsSqlClient/ConnectInstanceCommand.cs @@ -1,12 +1,13 @@ -using System; +using Azure.Core; +using Azure.Identity; using Microsoft.Data.SqlClient; -using Microsoft.Azure.Services.AppAuthentication; -using System.Management.Automation; -using System.Security; -using System.Runtime.InteropServices; +using System; +using System.Diagnostics; using System.IO; +using System.Management.Automation; using System.Net; -using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Security; namespace PsSqlClient { @@ -447,7 +448,9 @@ private void InitAuthenticationClass() WriteVerbose("Token will be acquired. Use token-based authentication."); _authenticationClass = AuthenticationClass.TokenAuthentication; - AccessToken = new AzureServiceTokenProvider().GetAccessTokenAsync(resource: Resource).Result; + AccessToken = new DefaultAzureCredential().GetToken( + new TokenRequestContext(scopes: new string[] { Resource + "/.default" }) { } + ).Token; WriteDebug($"AccessToken:${AccessToken}"); } else if (!string.IsNullOrWhiteSpace(AccessToken)) diff --git a/src/PsSqlClient/PsSqlClient.csproj b/src/PsSqlClient/PsSqlClient.csproj index 9824f83..2df8bc3 100644 --- a/src/PsSqlClient/PsSqlClient.csproj +++ b/src/PsSqlClient/PsSqlClient.csproj @@ -9,7 +9,7 @@ - +