Sample Script
The following is an example of a script that you add to the proxy Business Service's Service_PreInvokeMethod event handler when configuring OAuth support for Siebel REST outbound connections.
function Service_PreInvokeMethod(MethodName, Inputs, Outputs) {
//1. Get Access token from OAUTH server//
var EAIHTTPTrasnport = TheApplication().GetService("EAI HTTP Transport");
var Httpin = TheApplication().NewPropertySet();
var Httpout = TheApplication().NewPropertySet();
Httpin.SetProperty("HTTPRequestURLTemplate", "https://idcs-f03fb776674c40eb80487eb12f87a170.identity.c9dev2.
oc9qadev.com/oauth2/v1/token");
Httpin.SetProperty("HTTPContentType", "application/x-www-form-urlencoded;charset=UTF-16");
Httpin.SetProperty("HDR.Authorization", "Basic
YjZjYTYzNWM3YjcwNGFlYmE2NzQyNTJkYWM4YTVmYzU6YmJiOWJmZjUtYjE0NS00NTg0LTgwODItNGI4ODYwYzgwMmVk");
Httpin.SetProperty("HTTPRequestMethod", "POST");
Httpin.SetProperty("HTTPRequestBodyTemplate", "grant_type=client_credentials&scope=urn:opc:idm:
__myscopes__");
Httpin.SetProperty("HTTPAccept", "*/*");
Httpin.SetProperty("CharSetConversion", "UTF-8");
EAIHTTPTrasnport.InvokeMethod("SendReceive", Httpin, Httpout);
// Can be removed or commented after debugging complete
TheApplication().TraceOn("", "Allocation", "All");
TheApplication().Trace("START - TEST v1.0");
TheApplication().Trace(Httpout.GetValue());
TheApplication().Trace("END - TEST");
TheApplication().TraceOff();
//2. Extract access token from json to property set//
var Jsoconverter = TheApplication().GetService("Siebel XSL To XML Convertor");
var tokenPS = TheApplication().NewPropertySet();
Jsoconverter.InvokeMethod("jsontops", Httpout, tokenPS);
var token_type = tokenPS.GetProperty("token_type");
var access_token = tokenPS.GetProperty("access_token");
TheApplication().TraceOn("", "Allocation", "All");
TheApplication().Trace("START - TEST v2.0");
TheApplication().Trace(tokenPS.GetProperty("access_token"));
TheApplication().Trace(tokenPS.GetProperty("token_type"));
TheApplication().Trace(tokenPS);
TheApplication().Trace("END - TEST");
TheApplication().TraceOff();
//3. Add access token to proxy BS input property set//
Inputs.SetProperty("Authorization:header", token_type + " " + access_token);
return (ContinueOperation);
}
Modify Script (Optional)
Depending on your particular situation, you can change the previous sample script as shown in the following table.
Change | Description |
---|---|
HTTPRequestURL Template |
In the sample script shown here, the HTTPRequestURLTemplate is set to
|
HDR.Authorization |
Siebel must be registered in the Out bound server's (Resource Server) OAuth
server to get the client_id & client_secret, as follows:
|
To resolve a "Cannot connect to server error"
-
Create a domain user and add it to the local Administrators group (and set the password).
-
Add the local user to the Administrator group.
-
Log in to the Siebel application with the created local user.
-
Go to the Security section of your browser and ensure that the following are set:
-
Check for the publisher's certificate revocation
-
Check for the server's certificate revocation
-
Check that TLS1.2 is set to true
-
-
Open Services, go to the Siebel Server Service and log in with the local user credentials.
-
Restart the Siebel Service with that user (local user).