SecondThundeR / shikithon

Yet another Python wrapper for Shikimori API
https://pypi.org/project/shikithon/
MIT License
8 stars 0 forks source link

Fix refresh token on expiration #12

Closed SecondThundeR closed 1 year ago

SecondThundeR commented 1 year ago

Currently, in 2.2.0 version there is a bug, when token cannot be refreshed because Authorization header is set.

Obvious solution would be to implement a header cleanup when refreshing token

SecondThundeR commented 1 year ago

For now, I guess, this will probably fix this issue (Will be tested on next token expiration): https://github.com/SecondThundeR/shikithon/blob/738d97bf91951e4aea36927504e4b13cac5167d7/shikithon/base_client.py#L401-L414

SecondThundeR commented 1 year ago

Well, its better to move out this logic to own function (also, logic for updating is duplicated before response and after, when checking for code status): https://github.com/SecondThundeR/shikithon/blob/ec30392c4ba9991be22b1bd09d01fddf57a9bb04/shikithon/base_client.py#L562-L580

First use: https://github.com/SecondThundeR/shikithon/blob/ec30392c4ba9991be22b1bd09d01fddf57a9bb04/shikithon/base_client.py#L476-L480

Second use: https://github.com/SecondThundeR/shikithon/blob/ec30392c4ba9991be22b1bd09d01fddf57a9bb04/shikithon/base_client.py#L518-L521

SecondThundeR commented 1 year ago

Latest changes works fine and tokens update successfully (Bugfix pushed to PyPI)