RSS
 

Archive for February, 2015

PyQT not sending browser credentials with subsequent requests

04 Feb

I have been busy lately with Python’s Twisted and PyQT

I built this twisted based API server that requires basic username and password authentication to generate an acces token to be used with subsequent requests.

server works fine when tested with a web browser but i started having issues with the GUI works
I adopted PyQT because of it’s SIGNAL-SLOT approach to threading.

the issue i have with the GUI part is, after getting the access token, i store it in the singleton main application instance
so for every child widget that will interact with the main application instance, i simple pass the famous ‘self’ into the widget

one behaviour i get is this, subsequent requests with the access token passed along fails.

this is because of the way the twisted server reason.

Twisted assumes it is a new request everytime subsequent request is made, this is because at the background, Twisted returns a cookie named TWISTED_SESSION which it expects back. Unfortunately Qhttp isn’t sending it back to the server.

 

The solution to this is to send it back to the server with subsequent request.

it took about 2 hours to narrow down the problem, i hope you dont have to waste that much time on this.