Authenticating Socket.io Connections

An Experience of Trials and Tribulations

Caelin Sutch
1 min readDec 30, 2019
Photo by Chris Ried on Unsplash

I’m currently working on the backend infrastructure for GarbageBytes, a robotic trashcan company (yes, sounds weird, but trust me, it’s really cool). In the process, I had to delve into the world of sockets for real time data transmission from robot to server and server to user.

However, I ran into the problem of authentication. I found this, an unmaintained library for authentication using JWT. I use JWT tokens, so this seemed interesting, but I found the documentation lacking. Anyways, I made a little solution to do so, code below in case you’re interested.

Pretty straight forward. Of course, if you want to use JWT tokens in the middle to connect with a user that’s already authorized, feel free to do so.

Questions? Comment and I’ll get back to you :).

--

--

Caelin Sutch
Caelin Sutch

Written by Caelin Sutch

Founder, engineer, designer. Passionate about building cool shit.

Responses (1)