Good Afternoon all
We are trying to create a JS file from a third system to call Alfresco and obtain an authentication ticket. To do so we are using the webscript api and this is the JavaScript function we are building
function getTicket(login,password, numDoc, clave)
{
var urlTicket="http://urlAlfresco/service/api/login?u="+login+"&pw="+password;
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", urlTicket, false ); // false for synchronous request
xmlHttp.setRequestHeader('Access-Control-Allow-Headers', '*');
xmlHttp.setRequestHeader('Access-Control-Allow-Origin', '*');
xmlHttp.onload = function() {
var requestData = xmlHttp.responseText;
var ticket = "";
if ((requestData!=='')&&(requestData!==NULL)){ticket = requestData.toString().substring(47,94);}
if (ticket!=="")
{
window.location.href = "http://urlAlfresco/service/showContent?nFact="+numDoc+"&cPro="+clave+"&alf_ticket="+ticket;
}
}
xmlHttp.onerror=function(){alert("Not working");};
xmlHttp.send(null);
}
The problem is that when we try to make a call "request" GET, the function http://urlAlfresco/service/api/login is failing and is not giving us any response. (We have also tried the POST method but with the same wrong result)
We have readed in the forum that there seems to be a problem in Alfresco 4.2 with the Cors configuration. We have tried to apply the filters in the Cors configuration we found in the forums, but it is not working at all 😞
What it is strange is that if we introduce the url in the browser directly http://urlAlfresco/service/api/login?u=login&pw=password
the browser returns the ticket.... but we are not able to get it using a GET request call by JS
What we are trying to achieve is that a third system could be able (using a JS code) to make a call to the webscript login in Alfresto to obtain a ticket, and with that ticket call a custom webscript that we have created to show up the document we are looking for. However the question is, if it is not possible to use the method in the service http://urlAlfresco/service/api/login, what other options do we have to achieve this in JS? Is this still possible in 4.2 as it was in 3.0?
Thanks a lot in advance.