How to check if the restapi token is valid

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

How to check if the restapi token is valid

L2 Linker
4 REPLIES 4

L3 Networker

As far as DAP: My understanding is as follows but I'm not sure..

 

Generally, login API services will return the response as JSON body. There should be a Date field (ex: Date:"Fri, 18 Jun 2021 08:15:44 GMT"). I've taken this Date from DAP Access Token and this will be valid for 8 minutes.. And this will be automatically refreshed if there is any subsequent request within these 8 minutes time frames.

 

Thoughts?

I am using cyberark login as auth method and just get the session token ,no other info.

I want to make an api call to see if the token is valid

L4 Transporter

You can send a GET request using the token to one of the below endpoints:

/api/LoginsInfo /WebServices/PIMServices.svc/User /WebServices/PIMServices.svc/Server

L3 Networker

You could do this in powershell. Just replace baseURL,username,password. It should do the task.

 

$URL_CyberArkLogon = "https://<baseURL>/passwordvault/api/auth/cyberark/Logon"

$logonBody = @{ username=<$rstusername>;password=<$rstpassword> }

$logonToken = ""

$logonBody = $logonBody | ConvertTo-Json

$URL_CyberArkLogoff = "https://<baseURL>/passwordvault/api/auth/Logoff"

$logonHeader = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

 

 try{

  # Logon

   $logonToken = Invoke-RestMethod -Method Post -Uri $URL_CyberArkLogon -Body $logonBody -ContentType "application/json"

   }

  catch

{

Write-Host -ForegroundColor Red $_.Exception.Response.StatusDescription

$logonToken = ""

}

  If ($logonToken -eq "")

  {

    Write-Host -ForegroundColor Red "Logon Token is Empty - Cannot login"

    return

  }

  else

{write-host "Token value: $logontoken"}

$logonHeader.Add("Authorization", $logonToken)

  • 520 Views
  • 4 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!