Hi everybody!
I need get server events from my service, but I don’t know how to do this for TS and JS.
I understand correctly, after authentication, I receive messages for my user?
Оr should I do like the c# client?
You just need to authenticate with the browser once as the JsonServiceClient/ServerEventClient automatically shares and sends the same cookies and authenticated user session that’s established with the browser.
So if you authenticate via any means normally, you will connect as the authenticated user to the event-stream. e.g. hitting the /auth/twitter, /auth/facebook, /auth/github routes will authenticate via OAuth and when it redirects back to the http://chat.servicestack.net home page it will connect as the authenticated user.
Some options for authenticating with the JsonServiceClient
, e.g:
var client = new JsonServiceClient(baseUrl);
//Basic Auth
client.userName = userName;
client.password = password;
client.post(new AuthOnlyRequest());
//Credentials
var request = new Authenticate();
request.provider = "credentials";
request.userName = userName;
request.password = password;
var authResponse = await client.post(new Authenticate());
//Using JWT
var jwtToken = authResponse.bearerToken;
client.setBearerToken(jwtToken);
1 Like