Skip to content

Conversation

@TriggerAu
Copy link
Contributor

Note: This fix is premised on an assumption that the ApiKey parameter in the Configuration object is meant to be an ApiToken from the management interface, based on the details in the management.yaml (more in the bug report).

If the fix should be to add an extra attribute called ApiToken to the Configuration object let me know and Ill adjust the PR

I kept the work in two commits:

  • The openapi mustache template changes for the config and api calls
  • The generated ps1 files

Changes

  • ApiKey is now a string instead of a hashtable and takes the apiToken that is generated in the admin interface
  • ApiKeyPrefix is now a string instead of a hashtable and defaults to SSWS
  • The logic in the methods for ApiKey uses it in the Authorization portion of the request header for the api per the API docs: Authorization: SSWS {API Token}

The usage of this method is as below:

$Configuration = Get-OktaConfiguration
$Configuration.BaseUrl = 'https://myorg.okta.com'
$Configuration.ApiKey = 'myApiToken'
Invoke-OktaListUsers

the ApiKeyPrefix defaults to the SSWS value from the documentation

Issue #52

Other Note: Im not sure how the team maintain/ask contributors to adjust the version/build log, but if there is anything I can do to help in that regard just lemme know

These will change the module files so that if the ApiKey/Prefix is set then
the PS Module calls will use the ApiKey to set the Authorization header
using the encoding specified by the management APIs to be able to use at Okta

`Authorization: SSWS {API Token}`
…3 generator

This implements the fix in all the modules through the use of the generator via
```
openapi-generator-cli generate -g powershell -c config.json --skip-validate-spec
```

It changes the Configuration object so that the ApiKey and ApiKeyPrefix are strings
and not hashtables, and deploys the changed usage to all the API calls that had
code that will use them
@aniket-okta
Copy link
Contributor

Hi @TriggerAu

Thank you for proposing a solution to this critical bug! While your approach of changing ApiKey from a hashtable to a string would work, it would be a breaking change for existing code.

#94 has been merged which fixes the same bug while maintaining backward compatibility with the existing @{apitoken = "value"} structure. The fix directly assigns to $HeaderParameters["Authorization"] instead of creating an unused local variable.

Key differences:

This PR is being closed in favor of #94 to avoid breaking existing implementations. Thanks again for your contribution!

See: #94

@aniket-okta aniket-okta closed this Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants