Well, I believe that the Loopback token is built for use with the express request object. In the latest version (2.x), you can use it if you override AccessToken.findForRequest and implement it yourself.
But there is another approach to this, which is considered in the official documentation :
Basically, this involves using socketio-auth (which "provides hooks for implementing authentication in socket.io without using requests to send credentials is not a good security practice") and directly uses the AccessToken model.
I put the code here with a little simplification:
On the server side:
app.io = require('socket.io')(app.start()); require('socketio-auth')(app.io, { authenticate: function (socket, value, callback) { var AccessToken = app.models.AccessToken;
On the client side:
socket.on('connect', function() {
source share