[SOLVED] Authentication token

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
Post Reply
tsx
Posts: 16
Joined: Fri Sep 12, 2014 11:29 pm

[SOLVED] Authentication token

Post by tsx »

What is the default timeout for the authentication token? How can I change that?
I'm trying a get all the data from few large mail boxes (~350k mails + ~40k attachments). I'm trying to reuse the authentication token but I'm getting "auth credentials have expired" message after some time.
I'm using SOAP in conjunction with Java.
-tsx
skenkin
Posts: 35
Joined: Fri Sep 12, 2014 11:33 pm

[SOLVED] Authentication token

Post by skenkin »

Check this thread here
tsx
Posts: 16
Joined: Fri Sep 12, 2014 11:29 pm

[SOLVED] Authentication token

Post by tsx »

Thanks Skenkin, but I couldn't find answer to my question. Am I missing something?
I'm using the SoapHttpTransport class. The authentication tokens for my admin transport as well as user transport are timing out. It appears the timeout seems to be 1 hour.
Here is the piece of code I'm using to authenticate


Element request = Element.XMLElement.mFactory

.createElement(AdminService.DELEGATE_AUTH_REQUEST);
Element account = request.addElement(AdminService.E_ACCOUNT);

account.addAttribute(AdminService.A_BY, "id");

account.setText(accountID);

Element response = myAdminHttpTransport.invoke(request);

String authToken = response.getElement(AdminService.E_AUTH_TOKEN)

.getText();

myUserHttpTransport.setAuthToken(authToken);
String sessionId = response.getAttribute(

ZimbraSoapContext.E_SESSION_ID, null);
if (sessionId != null) {

myUserHttpTransport.setSessionId(sessionId);

}

This code doesn't show it, but after authenticating once, I store the session id and authentication token in a pool that I reuse instead of authenticating every time.
How can I increase the timeout for these tokens?
skenkin
Posts: 35
Joined: Fri Sep 12, 2014 11:33 pm

[SOLVED] Authentication token

Post by skenkin »

With the following code you can set the time the connection will be available:



DelegateAuthResponse dar = sp.delegateAuth(

Provisioning.AccountBy.name, userLogin, durationInSecond);

ZAuthToken authToken = dar.getAuthToken();

Options options = new Options(authToken, Z_ADMIN_URL);

ZMailbox zUserMailbox = new ZMailbox(options);

tsx
Posts: 16
Joined: Fri Sep 12, 2014 11:29 pm

[SOLVED] Authentication token

Post by tsx »

You are right. I figured it out yesterday. I added the "duration" attribute to my delegate authentication method and everything worked as expected.
I appreciate your help.
Thanks.
Post Reply