From 17f9b7be466d46607c33ca1b195125750fe9cafb Mon Sep 17 00:00:00 2001 From: mabaumgartner <42626826+mabaumgartner@users.noreply.github.com> Date: Tue, 3 Aug 2021 15:21:09 -0500 Subject: [PATCH] add select-cif3token calls --- Private/Select-ClientToken.ps1 | 2 +- Public/Get-CIF3Config.ps1 | 4 ---- Public/Get-CIF3Feed.ps1 | 2 ++ Public/Get-CIF3Indicator.ps1 | 2 ++ Public/Test-CIF3Auth.ps1 | 2 ++ 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Private/Select-ClientToken.ps1 b/Private/Select-ClientToken.ps1 index a840290..a0d50e4 100644 --- a/Private/Select-ClientToken.ps1 +++ b/Private/Select-ClientToken.ps1 @@ -20,7 +20,7 @@ function Select-ClientToken { } else { if ($Script:CIF3.ReadToken -and $RequestType -eq "Read") { - # use the read token only if token is not configured + # use the read token if configured Write-Verbose "Selecting read_token" return $Script:CIF3.ReadToken } diff --git a/Public/Get-CIF3Config.ps1 b/Public/Get-CIF3Config.ps1 index 9066849..8db1774 100644 --- a/Public/Get-CIF3Config.ps1 +++ b/Public/Get-CIF3Config.ps1 @@ -70,10 +70,6 @@ function Get-CIF3Config { if ($null -ne $TempObj.Token -and $null -eq $TempObj.ReadToken) { $TempObj.ReadToken = $TempObj.Token } - # backfill WriteToken prop if it's empty - if ($null -ne $TempObj.Token -and $null -eq $TempObj.WriteToken) { - $TempObj.WriteToken = $TempObj.Token - } # Nice oneliner to convert PSCustomObject to Hashtable: https://stackoverflow.com/questions/3740128/pscustomobject-to-hashtable $TempObj.PSObject.Properties | ForEach-Object -Begin { $h = @{ } } -Process { $h."$($_.Name)" = $_.Value } -End { $h } diff --git a/Public/Get-CIF3Feed.ps1 b/Public/Get-CIF3Feed.ps1 index 9e1c741..3eee6e4 100644 --- a/Public/Get-CIF3Feed.ps1 +++ b/Public/Get-CIF3Feed.ps1 @@ -92,6 +92,8 @@ function Get-CIF3Feed { begin { $Uri += '/feed' + $Token = Select-ClientToken -Token $Token -RequestType 'Read' + $Body = @{ } # PSBoundParameters contains only params where value was supplied by caller, ie, does not contain diff --git a/Public/Get-CIF3Indicator.ps1 b/Public/Get-CIF3Indicator.ps1 index e09fc5c..50d4007 100644 --- a/Public/Get-CIF3Indicator.ps1 +++ b/Public/Get-CIF3Indicator.ps1 @@ -91,6 +91,8 @@ function Get-CIF3Indicator { begin { $Uri += '/indicators' + $Token = Select-ClientToken -Token $Token -RequestType 'Read' + $Body = @{ } # PSBoundParameters contains only params where value was supplied by caller, ie, does not contain diff --git a/Public/Test-CIF3Auth.ps1 b/Public/Test-CIF3Auth.ps1 index a27eb07..e0d733c 100644 --- a/Public/Test-CIF3Auth.ps1 +++ b/Public/Test-CIF3Auth.ps1 @@ -44,9 +44,11 @@ function Test-CIF3Auth { begin { if ($VerifyWrite -eq $true) { $Uri += '/ping?write=1' + $Token = Select-ClientToken -Token $Token -RequestType 'Write' } else { $Uri += '/ping' + $Token = Select-ClientToken -Token $Token -RequestType 'Read' } }