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

CSRF token mismatch #25

Open
flybyray opened this issue Apr 20, 2024 · 1 comment
Open

CSRF token mismatch #25

flybyray opened this issue Apr 20, 2024 · 1 comment

Comments

@flybyray
Copy link

How you can handle errors like?

"Error: 2024-04-19 - CSRF token mismatch."

response = session.post(
ATTENDANCE_URL,
json=generate_attendance(
sys.argv[1],
STARTING_HOUR,
BREAK_HOUR,
WORKING_HOURS,
BREAK_TIME_MINUTES,
PROFILE_ID,
),
)
data = json.loads(response.text)
try:
message = f"Error: {attendance_date} - {data['error']['message']}"
except KeyError:
message = f"Success: attendance on {attendance_date} registered!"

@flybyray
Copy link
Author

When i put the XSRF-TOKEN from session.cookies into session.headers as X-CSRF-TOKEN and X-XSRF-TOKEN right before the session.post it works for me without this error message.

    session.headers.update(
        {
            "X-CSRF-TOKEN": session.cookies["XSRF-TOKEN"],
            "X-XSRF-TOKEN": session.cookies["XSRF-TOKEN"],
        }
    )

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

1 participant