Authenticate Socket.IO Connection using JSON Web Tokens (jwt) and the node-jwt-simple library
Connect socket with adding a token as a query parameter:
var socket = io.connect('http://localhost', {
query: 'token=abcdefghijklmnopqrstuvwxyz
});
var server = http.createServer(app);
var io = require('socket.io').listen(server);
io.configure(function() {
io.set('authorization', jwtAuth.auth('your jwt secret'));
});
io.sockets.on('connection', function(socket) {
console.log('decoded', socket.handshake.decoded); // decoded is your decided token
});