Hi, Is there a way to get the user id from the req...
# support-questions-legacy
l
Hi, Is there a way to get the user id from the request without calling the supertokens core (jn python)? Currently i do this:
Copy code
python
session = await get_session(request, session_required=True)
user_id = session.user_id
Because i need the user id for every request, this havely slows down my api calls.
r
hey @Luca
get_session is stateless most of the time
so it does not IO operation at all, and session verification should be very very quick
Are you observing a different behaviour?
l
@rp_st
Having this code:
Copy code
python
a = time()
try:
    session = await get_session(request, session_required=True)
except UnauthorisedError:
     raise AuthenticationError('Authentication failed')
b = time()
It takes about 0.3s
r
oh really! hmm. Can you open an issue about this on our github? We will have a look
it should not take this long
also, are you using a serverless function?
l
no
r
alright.
we will investigate this in the coming days. Thanks
if you could open an issue about this, it will be helpful to keep track
2 Views