cancel
Showing results for 
Search instead for 
Did you mean: 

ticket and webscripts

eg
Champ in-the-making
Champ in-the-making
I have a web script, 'GetDocuments', that returns a list of documents from a space that has CompanyHome as its top-level parent. In order to be able to  "see" things under company home the webscript needs to be authenticated. I can set the authentication mode to user/guest/.. etc and when I execute the webscript from a browser it prompts me for a login, I enter the login details on the web form  and it works fine - I get my list of documents.

I want to be able to call this webscript directly from a javascript client and I don't want to be prompted for login details. What I would like to be able to do is to call the 'login' webscript (service/api/login?u=admin&pw=admin) to get a ticket and then append the ticket to my 'GetDocuments' webscript (… &ticket=.TICKET_b8cfbdd9cc47ec9b24a7cdcb1f6a1ea9a13ee04e).

My questions are:

1. Is the above approach possible - using only scripting.

2. If not possible then is it possible to set the webscript up so that it does not require any authentication and then within the body of the webscript, prior do doing any repository access, login programmatically  within the webscript so that it has access to repository?
4 REPLIES 4

stevewickii
Champ in-the-making
Champ in-the-making
I'm surprised you haven't received an answer to this question yet.  I have the same question/problem.  The "companyhome" root object is not available when you set authentication to guest or none.  I'll let you know if I find out anything.  From the JavaScript/WebScript documentation at wiki.alfresco.com, I don't believe it is possible to authenticate using a webscript.  You may have to write a quick servlet Filter that invokes AuthenticationUtils.startSession(username, password) and places the ticket into session.

mikeh
Star Contributor
Star Contributor
The login webscript / append ticket method will work fine using "user" authentication.

The ticket should be passed in the alf_ticket parameter using the "/service" webscript servlet.

Mike

louise
Champ in-the-making
Champ in-the-making
Is this possible to verify validity of a ticket?

I couldn't find solution yet, but should be helpful…

mikeh
Star Contributor
Star Contributor
http://wiki.alfresco.com/wiki/HTTP_API_Reference#Package:_.2Forg.2Falfresco.2Frepository

If you make a GET request to /service/api/login/ticket/TICKET_… you'll either get back an HTTP 404 or 200 OK plus the ticket in the body.

Thanks,
Mike