https://supertokens.com/ logo
#general
Title
# general
b

BeeMoe

05/01/2022, 7:53 AM
i want to use supertokens_python with websockets in fastapi. is there a verify_session that works for a websocket route?
r

rp

05/01/2022, 8:07 AM
Hey @BeeMoe
Not really. You can initiate a web socket with a route that uses the very session function. But authentication of each event during the socket connection should be done by yourself.
b

BeeMoe

05/01/2022, 8:25 AM
Oh
Actually, let me ask a better question. Using a websocket route, how do I get the user logged in?
r

rp

05/01/2022, 8:29 AM
There could be multiple ways. One is that you can create a JWT using Session.createJWT function which contains the user id.
And then pass that to the websocket event
Another would be to use the session’s handle and from that you can query the userId from supertoeks. This would require a db call though
b

BeeMoe

05/01/2022, 8:31 AM
Okay
Thank you
im gonna try the first way you said
looking at the docs i cant find where .createJWT is
@rp
r

rp

05/02/2022, 4:48 AM
See in session.syncio or session.asyncio package
b

BeeMoe

05/02/2022, 6:36 AM
thank you
5 Views