
4wa7w (4wa7w) asked a question.
Newbie question, sorry. I want to get a list of authorized users from okta to sync with my custom web app. I got an apikey, and can successfully run the Postman examples. But when I try to use curl/bash, I get invalid session return. Please help.
curl -s -X GET 'https://<myorg>.okta.com/api/v1/apps/<myappid>/users' \
-H 'Host: <myorg>.okta.com' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: SWSS myoktaapikeyxxxxxxxxx' \
-H 'User-Agent: custom/1.0'

Paul give this script I just whipped up a try.
#!/bin/bash
. $1
declare -a curlArgs=('-H' "Accept: application/json" '-H' "Authorization: SSWS $apikey" '-H' "Content-Type: application/json")
curl -X GET "$url/api/v1/apps/$appid/users" "${curlArgs[@]}"
I put the url, apikey and appid variables in a properties file that I just sourced at run time but you can add them directly in if you desire. This should resolve your invalid session issue and get you the user info you desire.
Joe