How to access the session information coming in from a third party application in Django

38 views Asked by At

I Need to check whether a user is logged in to a third party application from a redirection request that comes from that application. This request must contain a session token and the credentials used to log in to that application. Assuming that they're present, how can I access this information from inside a Django application?

I tried SSO and Django Sessions, however couldn't find anything useful there. It would be really helpful to know if I am looking in the right place.

1

There are 1 answers

2
Roberto Rubertelli On

if you try

print(request.session.session_key)

sometimes the result is None. I don't know the reason. To solve the problem add this code in your view:

    if request.user.is_anonymous:
       request.session['cached_session_key'] = request.session.session_key

You will always have the session at your disposal. My apologies if I didn't understand your question