rhgrant10 / berserk

Python client for the lichess API
https://berserk.readthedocs.io
Other
142 stars 36 forks source link

inconsistent usage of session headers/authentication? #7

Closed WolfgangFahl closed 4 years ago

WolfgangFahl commented 4 years ago

Description

The session header for authentication seems not to be used consequently.

What I Did

Trying to let two bots play against each other. Some requests for the other bot are denied (so I assume see #6 ) due to invalid session handling.

rhgrant10 commented 4 years ago

Hi @WolfgangFahl, thanks for reporting this. Can you provide some example code that reproduces the problem? From my experience (and reading of the documentation) requests.Session objects persist the headers across multiple requests and headers passed into the request methods only take precedence for those particular requests.

WolfgangFahl commented 4 years ago

That's why in my fork i am always sending the authentication header.

rhgrant10 commented 4 years ago

According to the requests source code, the session copies the session headers into a new dict and then updates it with the headers passed into the request method, so it appears that berserk is already always passing all authorization headers present for every request. If you're seeing different behavior, then can you show the code that demonstrates the problem?

WolfgangFahl commented 4 years ago

It seemed to happen when I tried to let two lichess bots play against each other. That usecase isn't relevant for me anymore so I fear i'll not be able to reproduce the details. In the debugger it was clearly visible that the header dict was not used!

rhgrant10 commented 4 years ago

Gotcha. I'm going to close this ticket for now. If the issue recurs, feel free to re-open this ticket with any evidence you can gather :)