HTTP authentification issue

Post Reply
loicaigon
Advanced member
Posts: 362
Joined: Wed Jul 10, 2013 10:22 am

HTTP authentification issue

Post 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
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: HTTP authentification issue

Post 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.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
loicaigon
Advanced member
Posts: 362
Joined: Wed Jul 10, 2013 10:22 am

Re: HTTP authentification issue

Post 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 ;)
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: HTTP authentification issue

Post by jan_suhr »

You can use Postman to test your calls

https://www.getpostman.com/postman
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
loicaigon
Advanced member
Posts: 362
Joined: Wed Jul 10, 2013 10:22 am

Re: HTTP authentification issue

Post 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 );
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: HTTP authentification issue

Post 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
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
loicaigon
Advanced member
Posts: 362
Joined: Wed Jul 10, 2013 10:22 am

Re: HTTP authentification issue

Post 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
loicaigon
Advanced member
Posts: 362
Joined: Wed Jul 10, 2013 10:22 am

Re: HTTP authentification issue

Post 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
Post Reply