Page 1 of 1

HTTP authentification issue

Posted: Thu Oct 05, 2017 5:44 pm
by loicaigon
Hi,
I am writing a script calling the EFI FIery . I can login and get authentificated but as soon as I try to upload a file, I get rejected by the server (teh user is not authentificated). I think some token/cookie isn't properly stored.

Does Switch generates such cookies ?

Really lost here.

TIA for any help.

Loic

Re: HTTP authentification issue

Posted: Thu Oct 05, 2017 6:05 pm
by gabrielp
It depends on their authentication scheme. Sometimes, on success of authentication, it would provide an access token on the response that you could use on further requests. Switch probably can't save and reference cookies.

Re: HTTP authentification issue

Posted: Thu Oct 05, 2017 9:52 pm
by loicaigon
Hi Gabriel,

Yes that's probably the key here. Problem is the Fiery API response on login doesn't expose much. We saw some cookie settings but none of our attemps to use it has worked yet.

We will keep on trying tomorrow :P

Thanks anyway for your interest and care here and elsewhere ;)

Re: HTTP authentification issue

Posted: Fri Oct 06, 2017 7:24 am
by jan_suhr
You can use Postman to test your calls

https://www.getpostman.com/postman

Re: HTTP authentification issue

Posted: Mon Oct 09, 2017 12:01 pm
by loicaigon
Hi jan,

Thanks for entering in. Actually I did use Postman which helped a lot. I identified the issue but still not able to make it work.
Postman will keep the cookie from login call in memory. It then passes it again to the upload call and it all works fine.

The problem is that Switch doesn't keep the cookie in memory so I have to pass it on to the next http call. But this is where I failed.

Has any of you ever passed a cookie in some http call ?

None of these worked :\
//where theCookie is the token returned by the login call

theHTTP.addHeader ( "cookie", theCookie );

theHTTP.addHeader ( "Cookie", theCookie );

theHTTP.addHeader ( "Set-Cookie", theCookie );

theHTTP.addHeader ( "set-cookie", theCookie );

Re: HTTP authentification issue

Posted: Mon Oct 09, 2017 12:18 pm
by jan_suhr
There is a property, localFilePath : String that can store responses from the server as a file. Maybe that can be used to store the Cookie and read from it.

Jan

Re: HTTP authentification issue

Posted: Mon Oct 09, 2017 12:25 pm
by loicaigon
Hi Jan,

Thanks for the input. Actually I could get the cookie string but I can't get to pass it to the next request.

Loic

Re: HTTP authentification issue

Posted: Mon Oct 30, 2017 10:45 am
by loicaigon
HI all,

I think I found the problem. It seems (unless I am wrong) that Switch always close the connection once it did the http(s) call. In my case, the connection needs to remain open.

I tried to set headers so the connection keeps alive but it seems to be effectless. I got in touch with support and am waiting for their feedback.
FWIW

Loic