Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to basket api returns 403 forbidden when user is logged in #320

Open
realgyomei opened this issue Sep 18, 2023 · 5 comments
Open

Add to basket api returns 403 forbidden when user is logged in #320

realgyomei opened this issue Sep 18, 2023 · 5 comments

Comments

@realgyomei
Copy link

the add to basket api works just fine with an anonymous user but immediately the user is logged in, it starts returning 403 forbidden. I have 'oscarapi.middleware.ApiBasketMiddleWare','oscarapi.middleware.HeaderSessionMiddleware', in my middleware

@specialunderwear
Copy link
Member

I think you need to take a look at precisely what is being returned, there will be more information there.

@realgyomei
Copy link
Author

could not find any error message associated with it other than the status(forbidden), how do you propose I check what was returned?

@realgyomei
Copy link
Author

I console.logged the response and found this line.
responseJSON:
detail:
"CSRF Failed: CSRF token missing or incorrect."

@realgyomei
Copy link
Author

this is my middleware settings:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'oscarapi.middleware.HeaderSessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'oscarapi.middleware.ApiBasketMiddleWare',
]

@r-naeem-afzal
Copy link

The 'oscarapi.middleware.HeaderSessionMiddleware' expects you to send a 'Session-Id' header in the request to manage the session. The format of which is given in the documentation of the middleware.
https://django-oscar-api.readthedocs.io/en/stable/topics/middleware.html#header-session-middleware

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants