1

im trying to integrate React , django and django channels together , however im facing some trouble trying to authenticate the socket connection.

There are some posts over here: first link enter link description here

But they do not talk about how to utilize it over the front end portion.

There are some posts which recommends to put the token within the URL , for example :

WebSocket('wss://example.com/my-ws-endpoint/?token=' + token, ...)

But there seems to be lots of security red flags in doing so. Therefore is there a simple easy way to resolve the token authentication issue for channel websockets here?

neowenshun
  • 860
  • 1
  • 7
  • 21

1 Answers1

0

Please take a look at this. It uses a http-proxy middleware to put the token in the request header instead of putting it within the URL. Also, you can read about a good method of authentication in Django channels in this post.

Winston
  • 601
  • 1
  • 9
  • 29
  • 1
    Hey brother , thanks for taking the time to answer my question , i have read through the link you have provided me however , it seems abit complicated to implement. I have adopted another method which is to send tokens via a cookie header : [linkl](https://stackoverflow.com/questions/61413375/django-channels-custom-token-authenticated-websocket-keeps-disconnecting-err-con) – neowenshun Apr 24 '20 at 16:51