Hi.. we are using cookie based auth, class Onboarding(APIView): @method_decorator(verify_sessio...
n
Hi.. we are using cookie based auth, class Onboarding(APIView): @method_decorator(verify_session()) def put(self,request,role): user_id = request.supertokens.get_user_id() print("User_id: ", user_id) It is giving error as "request doesn't have supertoken" I want to access session in class based sync function
r
Hey @Namratha
which framework in python?
@mayank can help you here when he has time tomorrow.
n
django
r
im not sure how to do it in class based as you are doing. It has been solved before, so search on our discord. Otherwise we will wait for @mayank to help.
n
last time KS helped me in how to use verify session in class based, it is working. Now i want to access user_id from this session and update session with latest role
r
right. Let's wait for @mayank
n
ok thanks
m
@Namratha Can you show from where you've imported the
verify_session()
decorator?
n
from supertokens_python.recipe.session.framework.django.syncio import verify_session
@mayank I am using sync calls only
m
Ya I figured, so your
View
seems to be correct, can you confirm you've included the
supertokens_python
app in
INSTALLED_APPS
and
supertokens_python.framework.django.django_middleware.middleware
in the middleware stack?
n
Yes i have done this. when i tested function based api from postman app where i send bearer token in authorization header, i was able to get session inside the function. but now frontend is sending token in cookies
m
You can configure the frontend to send the access token in either the header or the cookie. The backend should be able to pick up either. However, I don't think the problem is related to the view being Class Based or Function Based. https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/sessions/token-transfer-method