in order to create a token with non-standard timeouts you'll need to use an admin account. We're working on creating tools for this, but for the moment you could use a script like this:
- Code: Select all
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Creates a token for another user running as an administrator.
"""
NAME = "public_user"
GROUP = "public_group"
IDLE = 0
LIVE = 60*60*24 # 1 day
ADMIN_PASS = "xxxSECRETxxx"
import omero
c = omero.client("localhost")
s = c.createSession("root", ADMIN_PASS)
try:
service = s.getSessionService()
principal = omero.sys.Principal()
principal.name = NAME
principal.group = GROUP
principal.eventType = "User"
session = service.createSessionWithTimeouts(principal, LIVE * 1000, IDLE * 1000)
uuid = session.getUuid().getValue()
idle = session.getTimeToIdle().getValue() / 1000
live = session.getTimeToLive().getValue() / 1000
print "Session created:"
print "uuid=%s" % uuid
print "idle=%s sec(s)" % idle
print "live=%s sec(s)" % live
finally:
c.__del__()
This will print out something like this:
- Code: Select all
$ PYTHONPATH=dist/lib/python python token.py
Session created:
uuid=6a41f31c-cf16-4fd1-8a89-42b89df66dd1
idle=0 sec(s)
live=86400 sec(s)
Let us know if this works for you.
Cheers,
~J.