Aramayis  Mkrtchyan
Aramayis Mkrtchyan

Reputation: 349

Authentication flow with jwt and socket io

My Socket.IO application requires that a user be authenticated before he/she can send a message and be connected for reading messages without authentication.

Below is a code sample based on the assumption that the client would login via a REST API, obtain a JWT and reconnect with the socket server using the received token:

var socket = io.connect('', {
  query: 'token=' + token
});

How do I construct the authentication flow for the application?

Upvotes: 1

Views: 2159

Answers (1)

Sprotte
Sprotte

Reputation: 541

I don't understand your Problem? Do you would like to know how you handle the jwt? Or when to make which call for login and obtaining a token? In my application the user logins via rest api getting a token and the you can use it like for example with these module https://github.com/auth0/socketio-jwt

Upvotes: 1

Related Questions