Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: ArturoRobles

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#793792
Hi,
How to create the client and client secret using the REST api?

My Problem:
1. I have master workspace using that client id and client secret I need to create the client id and client secret for the sub workspace using the REST API. Help me please. I need it really. Please do the needful.

Thanks, Jemiris
#793794
Create a trigger like this:
Code: Select all
if (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 206 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
NewRestAppForm.png (23.27 KiB) Viewed 2239 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
REST_Applications.png (23.53 KiB) Viewed 2239 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.
#793805
Oh I forgot the final step if you are doing this remotely with web services or REST. You probably want to use this trigger code:
Code: Select all
if (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();
}
Then after calling executeTrigger() or PUT /cases/{app_uid}/execute-trigger/{tri_uid}, then call getVariables() or GET /cases/{app_uid}/variables to retrieve the value of the clientId and secret variables.
saml authentication?

Hi, We use LDAP and Active Directory for SSO authe[…]

Trước sự phát triển nhanh của thị trường hi[…]

I found the solution, I used a simple SQL query to[…]

Hello guys, Is it possible to set a background ima[…]