cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] Logout using REST fails

mwildam
Champ in-the-making
Champ in-the-making
In my first attempts to program against Alfresco I managed to get the login working.

For the logout it takes xml instead of json by default - don't know why - anyway how exactly must the xml look like? I tried giving it just the ticket in post parameters.

I always get 403 Forbidden as the http result code.

How should this be done?

(And maybe somebody could answer why some functions want json and some xml - this is a strange mix of formats…)
18 REPLIES 18

nileshyadav326
Champ in-the-making
Champ in-the-making

Thanks for highlighting the issue. 

well did u find the solution for this issue? 

bgl
Champ on-the-rise
Champ on-the-rise
Ok I found the way to do it : simply by doing as usual when a script is authenticated…….. Using this call

"/api/login/ticket/"+p_TicketSession + "?alf_ticket="+p_TicketSession
is working. I have submitted another URL with my ticket and the ressource is not anymore accessible. So it is working 🙂

So forget my questions in my previous post 🙂

johanpi
Champ in-the-making
Champ in-the-making
It may sound stupid but I have no idea how to do this.

I did:
In the .ftl it redirected to this url… Where ticket = TICKET_ce0049993f48b9996c48dd1e855c22dd8b24f97d
location = "http://seraecmdev001.sita.co.za:8080/alfresco/service/api/login/ticket/${ticket}?alf_ticket=${ticket}"

It returns:
<ticket>TICKET_862b5e324cbd5f7bfc4d84ea5fa74be70aebca3d</ticket>

But the ticket is still valid.
Could you please supply an example.

Thanks
Johan

bgl
Champ on-the-rise
Champ on-the-rise
Hi Johan,

Don't worry it does not seem stupid at all ! I had the same question !!

Here is a method (from a servlet) to require disconnection (code does not compile since it requires some other classes but it should be quite easy to clean it up). I use the library restlet - http://www.restlet.org/ - here (most classes in this code are coming from it )


public void disconnect(String p_TicketSession,
      String p_Login,
      String p_Password) {
    // Alfresco is over HTTP
    Client client = new Client(Protocol.HTTP);

    // URL for Alfresco (I'm using an external servlet so I have to get the URL to reach Alfresco)
    String urlRequete = getBaseUrlServicesAlfresco() +
      "/api/login/ticket/"+p_TicketSession +
      "?"+PARAM_TICKET+"="+p_TicketSession;

    // NOTE HERE THE METHOD USED FOR REST CALL : DELETE and not POST or GET
    Request request = new Request(Method.DELETE, urlRequete);

    // Calling
    Response reponse = client.handle(requete);
    Status status = reponse.getStatus();
    int returnCode = status.getCode();

    // Checking return code
    if ( returnCode == SUCCESS ) {
      logDebug("Disconnection succeeded");
    } else {
      logDebug("Disconnection failed. Error code is : " + status.getCode());
      throw new RuntimeException("Disconnection failed with http error code "+ status.getCode());
    }

  }

Should make the work !

Boris

johanpi
Champ in-the-making
Champ in-the-making
We are primarily working in webscripts so java is not the way now.

I did:
location = "${url.context}/service/api/login/ticket/${ticket}?alf_method=DELETE"

Result:

<response>
−<status>
200

<name>OK</name>
<description>The request succeeded normally.</description>
</status>
−<message>
Deleted Ticket TICKET_9d42ac57c421c13c23af75c533bafdc3649d8003
</message>
<exception/>
<callstack>
  </callstack>
<server>Enterprise v3.3.1 (96) schema 4,013</server>
<time>06 Oct 2010 1:50:37 PM</time>
</response>

which seems to work. But as soon as I press back button, it assigns a new Ticket without asking to log in, which I can delete again without asking for a login.
The user is not logged out as the user van still do queries…

Any ideas?
Thanks

bgl
Champ on-the-rise
Champ on-the-rise
Did you try to use the ticket you had without using back button ? For instance use the ticket to list contents in a folder.

I ask this because your case seems to be : you delete the ticket and when pressing back, you automagically get connected with a new ticket (may be there are somewhere login/pwd and they are passed when you are not connected ?)

What you do to check this assertion (or discard it 🙂 ) is : get disconnected. Write the content of the ticket. Then Press back button and again disconnect. Another ticket is displayed. Compare the 2 tickets : they must be different.

What is the result of this test ?

johanpi
Champ in-the-making
Champ in-the-making
The ticket is deleted.

And I agree a new tickets is created. The 2 tickets differ.

bgl
Champ on-the-rise
Champ on-the-rise
So you have now to find out why a new ticket is created 😉

Boris

soriaedu79
Champ in-the-making
Champ in-the-making
Any clue about this second ticket?

I have the same problem.

Thank you