Atlassian recently changed the expiry behavior for API tokens so that you no longer are able to generate API tokens without expiry time. While I understand that this might be more secure if you update your tokens from time to time, I see the challenge that some automations will get authentication problems.
Is there an API available to check how long my API token is valid? This would enable to proactively check if it’s still valid and raise warnings if the token is about to expire.
Hello @matthias
I haven’t tried it yet, but you can use the Get all API tokens in an Org endpoint to find a specific API Token for a specific user, and in the response there is a data:expiresAt
object:
expiresAt string
An ISO-8601 formatted timestamp representing the time when a token expires.
Of course, access to that API endpoint is ‘outside’ of Jira and restricted to Org Admins with an appropriate access token.
Thank you for sharing that, @sunnyape.
Ideally, I’d like to call that endpoint with the same API token which is expiring. This endpoint could be ‘outside’ of Jira - would probably makes sense since the API token is also valid for Confluence (and other products).
Yep, it would be nice to use a token to lookup its own expiry date, but that doesn’t exist yet. It’s the GUI or nothing at the moment.
Did you know that the email address associated with a User API Token receives a notification the day before the token expires? You could use that to remind yourself to generate new tokens.
1 Like
Thanks to @sunnyape for pointing out the value is already in the API. Doc updates on the way.
I also take your point @matthias about a better token API for the consumer, not the admin. As such, I’m advocating for an elaboration on the accessible-resources
such that it would work for API Tokens and to return some other information such as token durations and API base URLs. That’s a longer-term concern.
2 Likes
Thank you, @ibuchanan - that would be exactly what I was searching for.