Skip to content

Commit

Permalink
add select-cif3token calls
Browse files Browse the repository at this point in the history
  • Loading branch information
mabaumgartner authored and mdavis332 committed Aug 3, 2021
1 parent 97272ec commit 17f9b7b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Private/Select-ClientToken.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 0 additions & 4 deletions Public/Get-CIF3Config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 2 additions & 0 deletions Public/Get-CIF3Feed.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Public/Get-CIF3Indicator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Public/Test-CIF3Auth.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down

0 comments on commit 17f9b7b

Please sign in to comment.