<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D51Y00006iSTLvSAOOkta Classic EngineIntegrationsAnswered2025-08-14T09:00:17.000Z2019-10-02T00:43:40.000Z2020-03-05T09:57:22.000Z

4wa7w (4wa7w) asked a question.

Invalid Session

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

    Expand Post
    Selected as Best
  • 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

    Expand Post
    Selected as Best
  • 4wa7w (4wa7w)

    Thanks, Joe. Worked like a charm!

  • RajasV.66419 (Customer)

    1. You should have following headers:

    {

    "Accept": "application/json",

    "Content-Type": "application/json",

    "Authorization": "SSWS $apiKey"

    }

     

    2. Make sure you spell the label for SSWS token as Authorization and not Authorisation ;)

     

    Expand Post
This question is closed.
Loading
Invalid Session