Skip to content

Commit

Permalink
moved to azure.identity
Browse files Browse the repository at this point in the history
  • Loading branch information
abbgrade committed Nov 29, 2023
1 parent 130bb45 commit e22d625
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/PsSqlClient/ConnectInstanceCommand.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/PsSqlClient/PsSqlClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.1" />
<PackageReference Include="System.Management.Automation" Version="7.2.16" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
<PackageReference Include="Azure.Identity" Version="1.10.4" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit e22d625

Please sign in to comment.