Fix unhelpful generic 401 error on AniList expiry (#3888)
A leftover of what I assume was the v1 API behaviour handling manually multiplied the `expires` values by 1,000, supposedly to make it a millisecond value. However, AL tokens have been saved as milliseconds since at least the v2 API implementation in 2018, so this has made every expiry comparison ludicrously impossible. Example: millisecond timestamp: 1788529931115 (2026-09-04T13:52:11.115Z) *1,000 1788529931115000 (+58646-04-04T21:45:15Z) So any expiry comparisons would say "yes this token is still totally valid", causing Mihon to send expired credentials and AL to respond with a 401. With these changes (which include some loosely associated clean-up), we now correctly identify expired credentials before we attempt any AL requests & actually show a toast with the "Token expired." error message for the first time in 8 years or so? I was able to keep the new ALOAuth shape compatible with already-serialized data, though whenever a user (re-)links AL from now on, both the `token_type` and `expiresIn` fields won't exist any more. Since they had no use in the current code anyway, I don't consider this a problem. I took the liberty of adding basic instructions to the error message but these can't be i18n'd properly so I kept it short and sweet. --- Side effect of expired credentials is Mihon erasing the token in storage, meaning AL disappears from the tracker sheet until re-linked. I would say this is acceptable, but we might see panicked users in support saying "Mihon deleted my AL links" or something.
This commit is contained in:
@@ -20,6 +20,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
||||
- Show updates and upcoming filter icon as active for categories ([@Secozzi](https://github.com/Secozzi)) ([#3772](https://github.com/mihonapp/mihon/pull/3772))
|
||||
- Show scores in MangaUpdates search results (and authors for `id:` prefix searches) ([@MajorTanya](https://github.com/MajorTanya)) ([#3795](https://github.com/mihonapp/mihon/pull/3795))
|
||||
- Remove whitespace from MAL and MB `id:` prefix search inputs before searching ([@MajorTanya](https://github.com/MajorTanya)) ([#3793](https://github.com/mihonapp/mihon/pull/3793))
|
||||
- Show a helpful error message for expired AniList credentials ([@MajorTanya](https://github.com/MajorTanya)) ([#3888](https://github.com/mihonapp/mihon/pull/3888))
|
||||
|
||||
### Fixed
|
||||
- Fixed app and extension update check running again on configuration change ([@AntsyLich](https://github.com/AntsyLich)) ([#3708](https://github.com/mihonapp/mihon/pull/3708))
|
||||
|
||||
Reference in New Issue
Block a user