Select to view content in your preferred language

How to programmatically check API key expiration

133
0
3 weeks ago
jdyerLACSD
Emerging Contributor

I'd like to write a Python script to run periodically and check the expiration date of my API keys, then email me about any that are expiring soon.  Currently, I can't figure out how to accomplish this with the ArcGIS Python API.

  • I tried using gis.api_keys.keys, but that only shows the old (deprecated) API keys
  • Then I tried gis.content.search("type:application"), which successfully fetches the new API key (developer credentials) items, plus all other application items.  It looked like the property "apiToken1ExpirationDate" would be the place to get the expiration dates, but it only returns the correct expiration date occasionally. Most of the time, it returns -1 instead.

Is there another way to get the expiration date for developer credential API keys?

0 Kudos
0 Replies