Thanks for your explanation.

I am really confused.
Actually the Pyramid app is setup on one server and the REST api (also in Pyramid ) is on a different machine.
It may be on the same server and we can asume that for simplicity sake.
Now when the frontend web app is started using pserve, the requests will open a connection to http://localhost:7081 where the rest api server is running. The user mey be on another machine and through browser sends a request to 192.168.1.25 the login page comes and the user sends username and password with organization name. The controller of the webapp gets this request and passes the data to the rest server in a json object through requests.post method.
The rest api returns a jwt object which I store in requests.session like:
s = requests.session.
s.headers["myheader": jwt_header]
I have not inclucded the line to get s.json_body because that was obvious.
Now when the user sends a new request to 192.168.1.25 for let's say getting list of accounts, the header needs to be sent so that the rest server checks the jwt for credentials. I wish to know if there are several users doing same thing, will pyramid generate individual requests.session objects so that their individual jwt objects can be stored in the respective session.headers? If not then I know certainly that I can use jquery and store the header in $window and use it when ever needed.
Happy hacking.
Krishnakant.
On Thursday 17 March 2016 10:43 PM, Jonathan Vanasco wrote:
I'm a little unclear on what you're trying to do, because 'session' and 'requests' are used do describe actions , objects and libraries.

I'm reading this as possibly being
   pyramid interacts with a 3rd party API using the `requests` library?
you want to run `requests` on some machine to interact with a 3rd party API and PyramidAPI
   you're talking about pyramid's request and request.session
   a few other things

What I can share is this:

If you're trying to use the `requests` library within `Pyramid` to use the JWT token, you will need to create/manage a new session object for the `requests` library on each `pyramid.request` (ie, "view"). Pyramid's `request.session` will persist across "requests" for a unique user, but `requests`' `Session` is usually used in a local scope. I'm not sure if it is safe or not to serialize and store in a pyramid session, so you might have to extract cookies and rebuild from scratch.
--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at https://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to