You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
when executing a graphql query to strawberry_django.auth.current_user() I get Forbidden (CSRF token from the 'X-Csrftoken' HTTP header incorrect.): /graphql
when using client sessions, and User is not logged in.
when not using sessions.
Previous calls to strawberry_django.auth.login() and strawberry_django.auth.register(UserRegister) work fine.
I do the following to get the csrftoken, which I set into the AIOHTTPTransport headers and cookies
async with aiohttp.ClientSession(cookie_jar=aiohttp.CookieJar()) as session:
csrf_token = None
# csrftoken are set by servers in GET calls
# TODO create a specific call for it?
async with session.get(self.url + "/admin") as resp:
assert_that(resp.status).is_equal_to(200)
for cookie in session.cookie_jar:
if cookie.key == "csrftoken":
csrf_token = cookie.value
assert csrf_token, "CSRF token not found in cookies"
return csrf_token
I also set CSRF_TRUSTED_ORIGINS
What am I doing wrong?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
when executing a graphql query to
strawberry_django.auth.current_user()
I getForbidden (CSRF token from the 'X-Csrftoken' HTTP header incorrect.): /graphql
when using client sessions, and
User is not logged in.
when not using sessions.
Previous calls to
strawberry_django.auth.login()
andstrawberry_django.auth.register(UserRegister)
work fine.I do the following to get the csrftoken, which I set into the AIOHTTPTransport headers and cookies
I also set CSRF_TRUSTED_ORIGINS
What am I doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions