[GH-ISSUE #267] [BUG] Tokens expiring too fast #45

Closed
opened 2026-02-27 08:11:35 +03:00 by kerem · 0 comments
Owner

Originally created by @geogamba on GitHub (Apr 19, 2024).
Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/267

Describe the bug
The token expiration conversion of seconds to microseconds is incorrect. I've been having problems with tokens expiring too fast, and narrowed it down to this problem.

Currently on core.py line 2281

def expired(self) -> bool:
            """ """
            return self.timestamp + (self.expires_in - TokenProvider.
                                     token_expire_threshold) * 1000 < int(
                                         time.time_ns() / 1000)

it should be

def expired(self) -> bool:
            """ """
            return self.timestamp + (self.expires_in - TokenProvider.
                                     token_expire_threshold) * 1000000 < int(
                                         time.time_ns() / 1000)

This should convert seconds to microseconds to match the self.timestamp and the time.time_ns() / 1000 (nanosecond converted to microseconds)

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Client Information (please complete the following information):

  • OS: [e.g. Windows]
  • Python Version [e.g. 3.9.0]
  • Library Version [e.g. 0.0.1]

Additional context
Add any other context about the problem here.

Originally created by @geogamba on GitHub (Apr 19, 2024). Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/267 **Describe the bug** The token expiration conversion of seconds to microseconds is incorrect. I've been having problems with tokens expiring too fast, and narrowed it down to this problem. Currently on `core.py` line 2281 ``` def expired(self) -> bool: """ """ return self.timestamp + (self.expires_in - TokenProvider. token_expire_threshold) * 1000 < int( time.time_ns() / 1000) ``` it should be ``` def expired(self) -> bool: """ """ return self.timestamp + (self.expires_in - TokenProvider. token_expire_threshold) * 1000000 < int( time.time_ns() / 1000) ``` This should convert seconds to microseconds to match the `self.timestamp` and the `time.time_ns() / 1000` (nanosecond converted to microseconds) **To Reproduce** Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. **Client Information (please complete the following information):** - OS: [e.g. Windows] - Python Version [e.g. 3.9.0] - Library Version [e.g. 0.0.1] **Additional context** Add any other context about the problem here.
kerem 2026-02-27 08:11:35 +03:00
  • closed this issue
  • added the
    bug
    label
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot-python-kokarare1212#45
No description provided.