Skip to main content
1-Visitor
April 5, 2022
Solved

List Of Application Keys and their expiration date

  • April 5, 2022
  • 1 reply
  • 1771 views

Hello,

 

I want to monitor the application keys and their expiration date

 

I tried two ways to list the application keys:

 

  • using GetEntityList() from EntityService

 var result = Resources["EntityServices"].GetEntityList({

  maxItems: 10000,

  nameMask: undefined,

  type: 'ApplicationKey',

});

 

But this give me an infotable with the following fields:

avatar, description, homeMashup, isSystemObject, name, tags

 

  • Then I tried SpotLightSearch:

const result = Resources["SearchFunctions"].SpotlightSearch({
maxItems: 1000000,
types: { items: [
"ApplicationKey"
]},
aspects: { isSystemObject: false },
maxSearchItems: 1000000
});

This give me an infotable wtih the following fields:

 delete, description, id, isEditable, isEditableExtensionObject, isEditableSystemObject, isExtension, isSystemObject, lastModifiedDate, name, parentName, parentType, read, type, update

 

So my problem is that both returned infotable that are not matching the ApplicationKey DataShape. 

And those infotable lack the userNameReference  field which could allow me to get the  ApplicationKeyExpirationInfoCollection (using GetApplicationKeyExpirationInfo

https://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/index.html#page/ThingWorx/Help/Composer/Security/ApplicationKeys/ApplicationKeyServices.html ) where I could have the reference user and expiration date.

 

How can I get a list of application key with their expiration date?

Thanks

Best answer by PaiChung

I think the second one provides 'name' from there can't you use ApplicationKeys[name].GetExpirationDate() ?

 

Beyond that here is another search function:

var params = {
maxItems: undefined /* NUMBER */,
searchExpression: "**" /* STRING */,
types:  { items: ["ApplicationKey"]} /* JSON */,
aspects: undefined /* JSON */,
excludedAspects: undefined /* JSON */,
maxSearchItems: undefined /* NUMBER */,
tags: undefined /* TAGS */
};

// result: INFOTABLE dataShape: EntityDescriptor
var result = Resources["SearchFunctions"].SearchModelEntities(params);

1 reply

PaiChung22-Sapphire IAnswer
22-Sapphire I
April 5, 2022

I think the second one provides 'name' from there can't you use ApplicationKeys[name].GetExpirationDate() ?

 

Beyond that here is another search function:

var params = {
maxItems: undefined /* NUMBER */,
searchExpression: "**" /* STRING */,
types:  { items: ["ApplicationKey"]} /* JSON */,
aspects: undefined /* JSON */,
excludedAspects: undefined /* JSON */,
maxSearchItems: undefined /* NUMBER */,
tags: undefined /* TAGS */
};

// result: INFOTABLE dataShape: EntityDescriptor
var result = Resources["SearchFunctions"].SearchModelEntities(params);

FredDL1-VisitorAuthor
1-Visitor
April 5, 2022

Thank you.

I thought that the search for the Applications Keys would return data with the Application Keys DataShape and not EntityDescripto (or else) but this seems logic afterwards

ApplicationKeys[name].GetExpirationDate() returns the expiration date that I need. So I will start from there!