I recently had question from a customer who wanted to automate the retrieval of the expiry for a given Cloud Services Platform (CSP) Refresh Token so that they could monitor it programmatically and setup notifications before the token expires. The CSP Refresh Token is required to interact with solutions within CSP including VMware Cloud on AWS (VMC).
Customers can check the current Refresh Token expiry along with the initiate create and last used time by navigating to "My Account" in the CSP UI and under "API Tokens" as shown in the screenshot below.
To retrieve this programmatically using the CSP REST API, you will need to provide a valid Refresh Token and then perform a POST am/api/auth/api-tokens/details
Here is an example using cURL:
curl -s -X POST -H "Content-Type: application/json" "https://console.cloud.vmware.com/csp/gateway/am/api/auth/api-tokens/details" -d "{tokenValue=$REFRESH_TOKEN}"
Similarly, for those that use PowerCLI and PowerShell, I have updated my PowerShell CSP community module to include a new function called Get-CSPRefreshTokenExpiry which will nicely return the formatted output given a Refresh Token as shown in the example below.
Get-CSPRefreshTokenExpiry -RefreshToken $RefreshToken
Thanks for the comment!