Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage examples contain incorrect function names and logic errors #63

Open
TriggerAu opened this issue Nov 2, 2024 · 1 comment
Open

Comments

@TriggerAu
Copy link
Contributor

TriggerAu commented Nov 2, 2024

In doing some work on a test framework to read and create Okta user profiles I looked at the read me and found the following issues in the below

# general setting of the PowerShell module, e.g. base URL, authentication, etc
$Configuration = Get-OktaConfiguration
# Configure your client ID and scope for authorization
$Configuration.ClientId = "YOUR_CLIENT_ID"
$Configuration.Scope = "OKTA_SCOPES" # for example okta.users.read
$PasswordCredentialHash = Initialize-PasswordCredentialHash -Algorithm "BCRYPT" -Salt "MySalt" -SaltOrder "MySaltOrder" -Value "MyValue" -WorkFactor 0
$PasswordCredentialHook = Initialize-PasswordCredentialHook -Type "MyType"
$PasswordCredential = Initialize-PasswordCredential -Hash $PasswordCredentialHash -Hook $PasswordCredentialHook -Value "MyValue"
$AuthenticationProvider = Initialize-AuthenticationProvider -Name "MyName" -Type "ACTIVE_DIRECTORY"
$RecoveryQuestionCredential = Initialize-RecoveryQuestionCredential -Answer "MyAnswer" -Question "MyQuestion"
$UserCredentials = Initialize-UserCredentials -Password $PasswordCredential -Provider $AuthenticationProvider -RecoveryQuestion $RecoveryQuestionCredential
$UserType = Initialize-UserType -Created (Get-Date) -CreatedBy "MyCreatedBy" -Default $false -Description "MyDescription" -DisplayName "MyDisplayName" -Id "MyId" -LastUpdated (Get-Date) -LastUpdatedBy "MyLastUpdatedBy" -Name "MyName" -Links @{ key_example = }
$CreateUserRequest = Initialize-CreateUserRequest -Credentials $UserCredentials -GroupIds "MyGroupIds" -VarProfile -Type $UserType # CreateUserRequest |
$Activate = $true # Boolean | Executes activation lifecycle operation when creating the user (optional) (default to $true)
$Provider = $true # Boolean | Indicates whether to create a user with a specified authentication provider (optional) (default to $false)
$NextLogin = "changePassword" # UserNextLogin | With activate=true, set nextLogin to ""changePassword"" to have the password be EXPIRED, so user must change it the next time they log in. (optional)
# Create a User
try {
$Result = New-OktaUser -Body $Body -Activate $Activate -Provider $Provider -NextLogin $NextLogin
} catch {
Write-Host ("Exception occurred when calling New-OktaUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
}

Annotated some issues I found here:

  1. These function names are missing the Okta after the dash
  2. This call is missing the parameter to pass in to VarProfile
  3. there is no value in the key_example

The VarProfile would need an object that contains the username, etc for the new user as a secondary bit once the code is able to run

image

A quick search of the broader readme's shows these repeated in a few places too

I did look to correct these in a PR, but Im not up to scratch enough on how the management.yaml is created to do this one quickly. If there is any sort of crib sheet on how to tweak these lemme know and I can help with these

@laura-rodriguez
Copy link
Collaborator

Thank you for reporting this issue and for continuing to help us make this tool better, @TriggerAu!

As you said, we must review the Okta OpenAPI spec and the templates. I filed an internal ticket for the team to review and prioritize in the upcoming planning rounds.

Internal Ref: OKTA-825952

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

No branches or pull requests

2 participants