Http redirect on auth service

Hi!
I need to redirect the service request which requires authentication, I have obtained and retained “ss-id” but for some reason the request fails.
Please tell me what am I doing wrong.

Additional question: how to redirect POST requests?

Thanks.

public object Get(Files request) {
            var session = SessionAs<MyAuthUserSession>();

            var httpResult = new HttpResult();
            httpResult.StatusCode = HttpStatusCode.Found;
            httpResult.Headers.Add(HttpHeaders.Location, host + Request.PathInfo);
            httpResult.Cookies.Add(new Cookie("ss-id", session.sessionCookieValue, host));
            
            return httpResult;
        }

Why are you setting cookies? If the url is in the same domain the client will automatically sends cookies for that domain.

Otherwise if you’re going to assign session cookies, you should assign all of them. Have a look at how we do this in Postman’s ExportSession feature:

var url = Request.GetBaseUrl()
    .CombineWith(Request.PathInfo)
    .AddQueryParam("ss-opt", Request.GetItemOrCookie(SessionFeature.SessionOptionsKey))
    .AddQueryParam("ss-pid", Request.GetPermanentSessionId())
    .AddQueryParam("ss-id", Request.GetTemporarySessionId());

return HttpResult.Redirect(url);
1 Like

Services in different domains, the first service is a customer for the second.

During authorization I get and save cookies to access the service, do something like this:

Tried it but not working…

That shows an example of the different session cookies you need to add, adding them on the QueryString wont do anything unless Config.AllowSessionIdsInHttpParams = true. By default you’d need to add them as Cookies.

1 Like

Here’s how it works, it was necessary to transfer the “ss-id” instead of “ssid”.

Thanks for the help!

 var url = host
           .CombineWith(Request.PathInfo)               
           .AddQueryParam("ss-id", cookies["ss-id"].Value);