Liem,
The On Premise Portal's PORTALMAN API provides a method for generating API Keys on the Gateway. Unfortunately, PORTALMAN is not documented or supported for external use at this time.
Alternatively, you may want to consider using API Key Custom Fields and database lookups to get done what you need. The Portal database stores different types of custom fields in different fields:
- Text is stored in cmssmalltextfield
- Numbers are stored in cmsnumberfield
- Dates are stored in cmsdatetimefield
- Special options are stored in cmsoptiontextfield
API keys are stored in the following tables:
- On the Gateway = generic_entity table
- On the Portal = lrs.lrsapplication and lrs.lrsapikey tables
You can use the databases to do lookups at runtime to reference information. For example, you may want to find the username of an OrgAdmin to which an API Key belongs. To do this, you need to map "API Key to OrgId to OrgAdmin" using the following lrs database tables:
If you have the OrgId, you can then retrieve the username by mapping OrgId -> userid -> username. Here's how:
- Lookup an apikey on the lrsapplication table to find the associated OrgId
- To map OrgId to userid do a lookup on the cmsorganizationusers table
- This may just return one userid (which would be the OrgAdmin for the organization), or it may return multiple userids for the OrgAdmin and all the Developers
- To map each userid (called an "id" in the cmsusers table) to a username do a lookup on the cmsusers table
In some cases, you may want to figure out which userid is the OrgAdmin and which userids are actually Developers. To do this, you need to know the following:
- The cmsuserroles contains a mapping between userid (called uid in this table) to roleid. Here, you can find that a specific userid might have a roleid of 12, for example.
- To find out what "12" means, do a lookup of roleid = 12 on the cmsroles table and you should find that it maps to "OrgAdmin" if there have been no changes made to the system.
------------------------------------------------------------------------------------------------------------------------------------------------
All of the above is rather complex, but is available today. Upcoming (by end of year) is our SaaS Portal API, which will be supported and documented for external use, and should simplify this use case greatly.