REST API ErrorCode":"PASWS006E","ErrorMessage":"The session token is missing, invalid or expired."}

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Welcome Idira to LIVEcommunity!

Our community just got stronger! Explore new identity security resources, connect with experts, and discover more ways to learn and collaborate.

Meet Idira

REST API ErrorCode":"PASWS006E","ErrorMessage":"The session token is missing, invalid or expired."}

L1 Bithead

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!

1 accepted solution

Accepted Solutions

L0 Member

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.

 

View solution in original post

3 REPLIES 3

L0 Member

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.

 

L1 Bithead

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

 

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

  • 1 accepted solution
  • 2204 Views
  • 3 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

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!