Create a trigger like this:
Code: Select allif (isset(@@appName) and !empty(@@appName)) {
require_once("classes/model/OauthClients.php");
$clientId = G::generateCode(32, 'ALPHA');
$secret = G::generateUniqueID();
$client = new OauthClients();
$client->setClientId($clientId);
$client->setClientSecret($secret);
$client->setClientName(@@appName); //Ex: 'Case Logger'
$client->setClientDescription(@@appDescription); //Ex: 'Logs cases remotely'
$client->setClientWebsite(@@appWebsite); //Ex: 'http://localhost:320'
$client->setRedirectUri(@@appCallback); //Ex: 'http://localhost:320/getToken.php'
$client->setUsrUid($_SESSION['USER_LOGGED']);
$client->save();
}
Here is a sample process that you can download which contains this trigger:
(28.46 KiB) Downloaded 388 times
You can create a case in this process to register a new REST application. Fill in the form with the details about your new REST application:
NewRestAppForm.png (23.27 KiB) Viewed 4465 times
When the form is submitted, it will create the REST application, which can be seen by redirecting your web browser to:
http://<domain-or-ip>/sys<workspace>/en/neoclassic/oauth2/applications
REST_Applications.png (23.53 KiB) Viewed 4465 times
If you want to execute this trigger remotely with web services, then first call
newCase() to create a new case, then call
sendVariables() to set the values of the appName, appDescription, appWebsite and appCallback variables in the case. Finally, call
executeTrigger() to execute the trigger using those variables.
Likewise, to execute this trigger remotely using REST, first use
POST /cases to create a new case in the process. Then, use
PUT /cases/{app_uid}/variable to set the values of the appName, appDescription, appWebsite and appCallback variables in the case. Finally, call
PUT /cases/{app_uid}/execute-trigger/{tri_uid} to execute the trigger using those variables.