I use Restsharp for a WPF client that I'm developing.
It appears that I receive no cookies in the client.CookieContainer where it has always 0 items after I successfully authenticate to our server.
It's weird because the same request is sent with Postman and I receive a JSESSIONID cookie that is not present when the request is sent with Restsharp.
public static async Task<IRestResponse> SendLogonRequest(string UID, SecureString pwd)
{
var restClient = new RestClient(new Uri(URLSRV))
{
Authenticator = new HttpBasicAuthenticator(UID, pwd.ToInsecureString()) //base64 auth;
};
restClient.CookieContainer = new CookieContainer();
var restRequest = new RestRequest(Method.POST);
restRequest.AddHeader("Accept", "application/json");
restRequest.AddHeader("Content-Type", "application/json");
var cancellationTokenSource = new CancellationTokenSource();
var restResponse = await restClient.ExecuteTaskAsync(restRequest, cancellationTokenSource.Token);
return restResponse;
}
I've seen on a post that if the cookie has a HttpOnly flag it will not work. (see: https://stackoverflow.com/a/21072840/7031019) this doesn't help me because I can't change anything from server side.
Thank you