Hi. I am using Jenkins 2.516.3. I am writing some custom code to manage Jenkins API tokens. The code needs to work for unprivileged users (so not require Jenkins admin privileges, which means no relying on Groovy scripting/etc). I have succeeded in creating an API token by calling crumbIssuer/api/json to get a crumb, and then user/USERNAME/descriptorByName/jenkins.security.ApiTokenProperty/generateNewToken to generate a new API token. I note that although it asks for a token name, there is no uniqueness – I can create as many tokens as I want with the same name, although each gets a different UUID. As well as /generateNewToken, there are also endpoints to revoke a specific token (/revoke), revoke all tokens (/revokeAll), revoke all tokens except one (/revokeAllExcept), and rename a token (/rename) – and I can invoke all of these endpoints successfully.
The one thing I can’t seem to do, is get the information included in the HTML screen (for each token the user has, its name, creation timestamp, last use timestamp, and UUID–the HTML doesn’t display the UUID to the user, but you can see it in the HTML source), in an easily machine-readable format, such as JSON or XML. Have I missed it, or does what I am looking for not exist?
Checking /api/json endpoint, I can see {"_class":"jenkins.security.ApiTokenProperty"}, but it never has any attributes no matter what I set the depth to.
Thank you
Simon Kissane