04-03-2017 04:54 AM
I'm using an AngularJS (1.6) SPA with the alfresco-js-api directly in the browser.
Thought I should be able to login with a valid ticket using
var ticket="XXXXXXXXXXXXX"; //valid ticket inside
var alfrescoApiInst = new AlfrescoApi({ provider:'ECM' });
alfrescoApiInst.loginTicket(ticket).then(function (data) {
console.log('valid ticket you are logged in');
}, function (error) {
console.error(error);
});
but this is not working.
But using the ticket in the constructor works
var alfrescoApiInst=new AlfrescoApi({ticketEcm:ticket,hostEcm:hostUrl,provider:"ECM"});
It works with the constructor, but did I miss anything or got it totally wrong?
04-04-2017 03:14 AM
Hi Martin,
I opened an issue for you :
loginTicket(ticket) 400 response · Issue #209 · Alfresco/alfresco-js-api · GitHub
please refer to it for further update.
In the meantime, I suggest you use constructor way.
04-03-2017 06:25 AM
Hi Martin,
Which is the error you get?
04-03-2017 06:47 AM
Hi Francesco,
I obtain the ticket through a alfresco web-script that returns a javascript object (template):
alfUserData={
"ticket":"${sessionticket.ticket}",
"firstName":"${person.properties.firstName}",
"lastName":"${person.properties.lastName}",
"userName":"${person.properties.userName}",
"email":"${person.properties.email}"
};
this is loaded as script before the angularJs app and called via wcs to use the configured SSO mechanism.
<script src="alfresco/wcs/autoticket"></script>
so I avoid the fiddling with the asynchrony and I have a valid global (initial) ticket before starting the next javascript.
But when using the loginTicket(ticket) there is an internal-error on calling the "loginTicket" method:
alfresco-js-api.min.js:6 OPTIONS http://127.0.0.1:8080/alfresco/api/-default-/public/authentication/versions/1/tickets/-me- 401 (Unauthorized)
Calling the constructor with the ticket is ok. But I fear I really missunderstood something.
I have to say, in this case I'm not on nodeJs, it's just a SPA hosted on the alfresco site.
...and now I see alfresco-js-api.min.js is calling the host http://127.0.0.1:8080 but it should call http://dms - and because I also run an alfresco locally this gives the unauthorized error - the ticket is not valid for another alfresco system
But everything is initialized with url http://dms - is http://127.0.0.1:8080 hardcoded in the js-api or am I missing just the ecmhost parameter...
Didn't recognize the wrong 127.0.0.1 before...
Happy Office hours
04-03-2017 07:19 AM
now I get
"errorKey":"Ticket base authentication required.","statusCode":400,"briefSummary":"03030007 Ticket base authentication required."
04-04-2017 03:14 AM
Hi Martin,
I opened an issue for you :
loginTicket(ticket) 400 response · Issue #209 · Alfresco/alfresco-js-api · GitHub
please refer to it for further update.
In the meantime, I suggest you use constructor way.
Explore our Alfresco products with the links below. Use labels to filter content by product module.