- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
Our community just got stronger! Explore new identity security resources, connect with experts, and discover more ways to learn and collaborate.
07-15-2022 10:51 AM
Hello CyberArk support, im a developer and we are trying to use the CyberArk REST API to do some automation; I am able to successfully authenticate (LOGON) and get a session authorization token string. When I make subsequent REST request, we are passing the authorization token as a header and we are getting the error "ErrorCode":"PASWS006E","ErrorMessage":"The session token is missing, invalid or expired."} ; This system appears to be behind a load balancer and I read another suggestion to attempt to pass both the Authorization and the cookies to the request which I tried however I am still getting the same error. I need your help to resolve the issue and I have the debug logs which I can also share to help us assure we have all set correctly, thanks!
07-16-2022 12:53 PM
I did received this error some time back while working on REST API, Cyberark has 2 generation API so if you fetch the token using 1st gen API and store it in a Variable to consume in 2nd gen API commands it might give this error.
For 1st gen you can use below commands to store the token and use it.
$LogonUrl="https://<IIS_Server_Ip>/PasswordVault/WebServices/auth/Cyberark/CyberArkAuthenticationService.svc/Logon"
$Sessiontoken = Invoke-RestMethod -Method POST -Uri $LogonUrl -ContentType "application/json" -Body (ConvertTo-Json $logonbody)
#Extract Token
$token = $sessionToken.psobject.properties.value
#Create Headers
$Global:headers= @{Authorization = $token}
You can use $headers in other 1st gen API's as below:
$ResultSafeadd = Invoke-RestMethod -Method POST -Uri $Addsafeurl -ContentType "application/json" -Headers $headers -Body (ConvertTo-Json $addsafebody)
And for 2nd gen you can use below commands to store the token and use it.
$LogonUrl= "https://<IIS_Server_Ip>/PasswordVault/API/auth/Cyberark/Logon"
$sessionToken = Invoke-RestMethod -Method POST -Uri $LogonUrl -ContentType "application/json" -Body (ConvertTo-Json $logonbody)
#Create Headers
$Global:headers= $sessionToken
You can use $headers in other 2nd gen API's as below:
Invoke-RestMethod -Method POST -Uri $logoffurl -ContentType "application/json" -Headers $headers
Hope this will help to resolve your issue.
Thanks.
07-16-2022 12:53 PM
I did received this error some time back while working on REST API, Cyberark has 2 generation API so if you fetch the token using 1st gen API and store it in a Variable to consume in 2nd gen API commands it might give this error.
For 1st gen you can use below commands to store the token and use it.
$LogonUrl="https://<IIS_Server_Ip>/PasswordVault/WebServices/auth/Cyberark/CyberArkAuthenticationService.svc/Logon"
$Sessiontoken = Invoke-RestMethod -Method POST -Uri $LogonUrl -ContentType "application/json" -Body (ConvertTo-Json $logonbody)
#Extract Token
$token = $sessionToken.psobject.properties.value
#Create Headers
$Global:headers= @{Authorization = $token}
You can use $headers in other 1st gen API's as below:
$ResultSafeadd = Invoke-RestMethod -Method POST -Uri $Addsafeurl -ContentType "application/json" -Headers $headers -Body (ConvertTo-Json $addsafebody)
And for 2nd gen you can use below commands to store the token and use it.
$LogonUrl= "https://<IIS_Server_Ip>/PasswordVault/API/auth/Cyberark/Logon"
$sessionToken = Invoke-RestMethod -Method POST -Uri $LogonUrl -ContentType "application/json" -Body (ConvertTo-Json $logonbody)
#Create Headers
$Global:headers= $sessionToken
You can use $headers in other 2nd gen API's as below:
Invoke-RestMethod -Method POST -Uri $logoffurl -ContentType "application/json" -Headers $headers
Hope this will help to resolve your issue.
Thanks.
07-18-2022 09:14 AM
Thanks saurbhargava , we are using the 2nd gen API as shared on the documentation site for all the calls as it said it was recommended we also received suggestion to assure sticky session is enabled on the load bal, and we're revalidating that we are correctly passing the received "Cookie" variables in the request headers, will update if we are still blocked on the issue
07-18-2022 03:25 PM
We switched to the 1st gen logon API as you suggested and the behavior appears more stable in the customer environment. We are still stress testing and evaluating the behavior in the various environments , i sincerely appreciate your time and our QA will be further assessing, but things appear stable after the change
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!

