WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • Apple
You are here: Home / Automation / How to retrieve the CSP Refresh Token expiry using the CSP API

How to retrieve the CSP Refresh Token expiry using the CSP API

01.11.2019 by William Lam // Leave a Comment

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

More from my site

  • PowerShell for PhotonOS on Raspberry Pi 3
  • Managing Distributed Firewall Rules in VMC using PowerShell & NSX-T Policy API
  • Automation with the VMware Cloud Services Platform (CSP)
  • 5 ways to a run PowerCLI script using the PowerCLI Docker Container
  • VMware PowerCLI for Mac OS X, Linux & More? Yes, please!

Categories // Automation, VMware Cloud on AWS Tags // Cloud Services Platform, CSP, PowerCLI, powershell

Thanks for the comment! Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native technologies, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC)

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • Self-Contained & Automated VMware Cloud Foundation (VCF) deployment using new VLC Holodeck Toolkit 03/29/2023
  • ESXi configstorecli enhancement in vSphere 8.0 Update 1 03/28/2023
  • ESXi on Intel NUC 13 Pro (Arena Canyon) 03/27/2023
  • Quick Tip - Enabling ESXi Coredumps to be stored on USB 03/26/2023
  • How to disable the Efficiency Cores (E-cores) on an Intel NUC? 03/24/2023

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2023

 

Loading Comments...