okta / okta-powershell-cli

Powershell CLI for communicating with the Okta API
Other
15 stars 4 forks source link

update the readme #40

Open gabrielsroka opened 3 months ago

gabrielsroka commented 3 months ago
# Use SSWS token instead of access token.
$Configuration = Get-OktaConfiguration
$Configuration.BaseUrl = 'https://YOURORG.okta.com/'
$Configuration.DefaultHeaders = @{authorization = 'SSWS ...'}

Get-OktaUser me

New-OktaUser @{
  profile = @{
    firstName = 'Okta'
    lastName = 'CLI'
    login = 'oktacli@example.com'
    email = 'EXAMPLE@gmail.com'
  }
}

# To get pagination to work is a little wonky using the example in the README.
# https://github.com/okta/okta-powershell-cli#list-users-with-pagination
$page = Invoke-OktaListUsers -WithHttpInfo -Filter 'profile.lastName eq "Doe"'
$users = $page.response
foreach ($user in $users) {
    write-host $user.id $user.profile.login
}
While ($page.NextPageUri) {
    # This time you can pass the absolute Uri with already contains query params such as "limit" or/and "after".
    $page = Invoke-OktaListUsers -Uri $page.NextPageUri -withHttpInfo
    $users = $page.response
    # have to repeat this loop from above....
    foreach ($user in $users) {
        write-host $user.id $user.profile.login
    }
}

# Using splatting is less redundant and more elegant (imho). this is how i did it in my pwsh module, too.
# based on https://github.com/gabrielsroka/OktaAPI.psm1#usage
$params = @{WithHttpInfo = $true; Filter = 'profile.lastName eq "Doe"'}
do {
    $page = Invoke-OktaListUsers @params
    $users = $page.response
    foreach ($user in $users) {
        write-host $user.id $user.profile.login
    }
    # This time you can pass the absolute Uri with already contains query params such as "limit" or/and "after".
    $params = @{uri = $page.NextPageUri; WithHttpInfo = $true}
} while ($page.NextPageUri)
gabrielsroka commented 3 months ago

also, after creating the app, assign yourself to it. i'm not sure it's in the docs (if it is, i might have missed it)

gabrielsroka commented 3 months ago

on

https://github.com/okta/okta-powershell-cli/blob/551fa3388a6e4aa80501470fb192eb7cf1db80b1/openapi3/codegen-templates/api_client.mustache#L260

and

https://github.com/okta/okta-powershell-cli/blob/551fa3388a6e4aa80501470fb192eb7cf1db80b1/openapi3/codegen-templates/api_client.mustache#L317

what is -MIME ?

laura-rodriguez commented 3 months ago

@gabrielsroka Thanks for the feedback! We're currently collecting feedback through multiple channels and plan to revisit the readme to make it clearer.

Internal Ref: OKTA-727813

laura-rodriguez commented 3 months ago

Related to #36