using alfresco-js-api in the browser, I can only login using the ecm-ticket in the constructor

cancel
Showing results for 
Search instead for 
Did you mean: 
mehe
Senior Member II

using alfresco-js-api in the browser, I can only login using the ecm-ticket in the constructor

Jump to solution

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?

1 Solution

Accepted Solutions
eugenio_romano
Alfresco Employee

Re: using alfresco-js-api in the browser, I can only login using the ecm-ticket in the constructor

Jump to solution

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.

View solution in original post

7 Replies
fcorti
Alfresco Employee

Re: using alfresco-js-api in the browser, I can only login using the ecm-ticket in the constructor

Jump to solution

Hi Martin,

Which is the error you get?

mehe
Senior Member II

Re: using alfresco-js-api in the browser, I can only login using the ecm-ticket in the constructor

Jump to solution

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 Smiley Happy 

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

mehe
Senior Member II

Re: using alfresco-js-api in the browser, I can only login using the ecm-ticket in the constructor

Jump to solution

now I get 

"errorKey":"Ticket base authentication required.","statusCode":400,"briefSummary":"03030007 Ticket base authentication required."

eugenio_romano
Alfresco Employee

Re: using alfresco-js-api in the browser, I can only login using the ecm-ticket in the constructor

Jump to solution

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.

mehe
Senior Member II

Re: using alfresco-js-api in the browser, I can only login using the ecm-ticket in the constructor

Jump to solution

Hi Eugenio,

thank you very much Smiley Happy

fcorti
Alfresco Employee

Re: using alfresco-js-api in the browser, I can only login using the ecm-ticket in the constructor

Jump to solution

Hi Martin,

The team released the ADF 1.3 LA few hours ago with the bugfix to this problem included.
Release 1.3.0 · Alfresco/alfresco-ng2-components · GitHub 

Maybe you are interested to the JS-API release note.

Release 1.3.0 · Alfresco/alfresco-js-api · GitHub 

Check it out!
(and many thanks to the team)

mehe
Senior Member II

Re: using alfresco-js-api in the browser, I can only login using the ecm-ticket in the constructor

Jump to solution

Hi Francesco and Eugenio,

no more login problems with the 1.3.0 Release  The issue is resolved. That was fast 

Thank you very much (the whole team)