@@ -121,10 +121,9 @@ function Connect-FabricAccount {
121
121
if ($PSCmdlet.ShouldProcess (" Setting Fabric authentication token and headers for $ ( $azContext.Account ) " )) {
122
122
Write-Message " Get authentication token from $ ( $FabricSession.ResourceUrl ) " - Level Verbose
123
123
$FabricSession.AccessToken = (Get-AzAccessToken - ResourceUrl $FabricSession.ResourceUrl )
124
- $ssPtr = [System.Runtime.InteropServices.Marshal ]::SecureStringToBSTR($FabricSession.AccessToken.Token )
125
- $Token = ([System.Runtime.InteropServices.Marshal ]::PtrToStringBSTR($ssPtr ))
124
+ $plainTextToken = $FabricSession.AccessToken.Token | ConvertFrom-SecureString - AsPlainText
126
125
Write-Message " Setup headers for Fabric API calls" - Level Debug
127
- $FabricSession.HeaderParams = @ {' Authorization' = " Bearer {0}" -f $Token }
126
+ $FabricSession.HeaderParams = @ {' Authorization' = " Bearer {0}" -f $plainTextToken }
128
127
129
128
# Copy session values to exposed $FabricConfig
130
129
$FabricConfig.TenantId = $FabricSession.AccessToken.TenantId
@@ -135,10 +134,9 @@ function Connect-FabricAccount {
135
134
if ($PSCmdlet.ShouldProcess (" Setting Azure authentication token and headers for $ ( $azContext.Account ) " )) {
136
135
Write-Message " Get authentication token from $ ( $AzureSession.BaseApiUrl ) " - Level Verbose
137
136
$AzureSession.AccessToken = (Get-AzAccessToken - ResourceUrl $AzureSession.BaseApiUrl )
138
- $ssPtr = [System.Runtime.InteropServices.Marshal ]::SecureStringToBSTR($AzureSession.AccessToken.Token )
139
- $Token = ([System.Runtime.InteropServices.Marshal ]::PtrToStringBSTR($ssPtr ))
137
+ $plainTextToken = $AzureSession.AccessToken.Token | ConvertFrom-SecureString - AsPlainText
140
138
Write-Message " Setup headers for Azure API calls" - Level Debug
141
- $AzureSession.HeaderParams = @ {' Authorization' = " Bearer {0}" -f $Token }
139
+ $AzureSession.HeaderParams = @ {' Authorization' = " Bearer {0}" -f $plainTextToken }
142
140
}
143
141
144
142
}
0 commit comments