-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Description
In this block of code the APIKey and Prefix are used to eset a varioable called $headers, but that variable is not used after that as part of the send to Invoke-WebRequest
okta-powershell-cli/src/Okta.PowerShell/Private/OktaApiClient.ps1
Lines 82 to 86 in 411f0f6
| if ($Configuration.ApiKey -and $Configuration.ApiKeyPrefix) { | |
| $headers = @{ | |
| Authorization = "$($Configuration.ApiKeyPrefix) $($Configuration.ApiKey.apitoken)" | |
| } | |
| } |
This means that this part of the documentation fails as it never passes an Authorization header
Lines 469 to 482 in 411f0f6
| The ApiKey property contains the API token, and ApiKeyPrefix should be used to prefix the token when setting the Authorization header. | |
| The OktaConfiguration object includes two important properties for API authentication: | |
| ApiKey: This should contain the actual API token in the form of a hashtable, e.g., @{ apitoken = '<yourApiToken>' }. | |
| ApiKeyPrefix: This is an optional prefix (default: "SSWS") to be used before the API token when setting the Authorization header. | |
| Example Usage: | |
| ```powershell | |
| $Configuration = Get-OktaConfiguration | |
| $Configuration.BaseUrl = 'https://your-org.okta.com' | |
| $Configuration.ApiKey = @{ apitoken = '<yourApiToken>' } | |
| $Configuration.ApiKeyPrefix = "SSWS" # Optional, defaults to "SSWS" | |
| ``` | |
| The resulting HTTP header will be: | |
| ```powershell | |
| Authorization: SSWS <yourApiToken> |
The fix to this is to update the Authorization header inside the if statement so its passed on to the next call as below
if ($Configuration.ApiKey -and $Configuration.ApiKeyPrefix) {
$HeaderParameters["Authorization"] = "$($Configuration.ApiKeyPrefix) $($Configuration.ApiKey.apitoken)"
}
Will raise a PR shortly including the Mustache fix for this - which will fix part of #90 as well
Metadata
Metadata
Assignees
Labels
No labels