With Cordova ios 6.2.0 along with cordova-plugin-wkwebview-file-xhr, the authentication cookie is retained and passed with all xhr requests in ios…this was a big victory.
However when using the websocket refresh option of a server connect, the cookie is not similarly passed and therefore the server connect responds with a 401 unauthorized.
This request is to allow for the use of websocket refresh on server connect’s that are restricted and thus need cookie support.
I think we must have a different authentication method for this, websockets don’t support session cookies. Instead of a cookie based authentication we could introduce a token based authentication system, like oauth2 you authenticate with the server and request a token which you then use with each api request.
The serverconnect refresh uses the websocket to update itself, you could instead of using the refresh a standard load, emit an event from the server that a reload is needed (just like with the refresh) and on the client listen to that event and trigger the load method of the serverconnect.
Okay, using Emit instead of Live Refresh works great. Thanks for the solution.
I’m curious how the two differ?
I would have thought the two patterns were roughly the same??? Don’t both of them emit to the clients and then the clients refresh the server connects?
Yes, both emit to the client but it differs in how it then updates the data. The refresh uses the socket connection to retrieve the data while the emit and the the load method does a new http request (which will contain the cookie).
1 Like