[GH-ISSUE #310] [BUG] 403 error when trying to log in #57

Closed
opened 2026-02-27 08:11:40 +03:00 by kerem · 1 comment
Owner

Originally created by @ghost on GitHub (Aug 15, 2025).
Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/310

Trying to log in with librespot.core.Session.Builder().oauth().create() throws this error:

Traceback (most recent call last):
  File "/.../librespot-python/test.py", line 2, in <module>
    session = Session.Builder().oauth(print).create()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../librespot-python/librespot/core.py", line 1677, in create
    session.authenticate(self.login_credentials)
  File "/.../librespot-python/librespot/core.py", line 985, in authenticate
    self.dealer().connect()
  File "/.../librespot-python/librespot/core.py", line 481, in connect
    self.__session.tokens().get("playlist-read"),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../librespot-python/librespot/core.py", line 2281, in get
    return self.get_token(scope).access_token
           ^^^^^^^^^^^^^^^^^^^^^
  File "/.../librespot-python/librespot/core.py", line 2301, in get_token
    response = self._session.mercury().send_sync_json(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../librespot-python/librespot/mercury.py", line 186, in send_sync_json
    raise MercuryClient.MercuryException(response)
librespot.mercury.MercuryClient.MercuryException: status: 403

It seems to happen after OAuth login, as a credentials.json file is created despite the error, and the error occurs without the OAuth callback if it's retried with the credentials.json file present.

To Reproduce
Steps to reproduce the behavior:

  1. Run this code:
from librespot.core import Session
session = Session.Builder().oauth(print).create()
  1. Paste the OAuth link into a browser and log in with a valid Spotify account
  2. Watch the error happen after logging in

Expected behavior
The login is successful.

Client Information (please complete the following information):

  • OS: Linux Mint 22.1
  • Python Version: 3.12.3
  • Library Version: The latest version from the repo
Originally created by @ghost on GitHub (Aug 15, 2025). Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/310 Trying to log in with `librespot.core.Session.Builder().oauth().create()` throws this error: ``` Traceback (most recent call last): File "/.../librespot-python/test.py", line 2, in <module> session = Session.Builder().oauth(print).create() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/.../librespot-python/librespot/core.py", line 1677, in create session.authenticate(self.login_credentials) File "/.../librespot-python/librespot/core.py", line 985, in authenticate self.dealer().connect() File "/.../librespot-python/librespot/core.py", line 481, in connect self.__session.tokens().get("playlist-read"), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/.../librespot-python/librespot/core.py", line 2281, in get return self.get_token(scope).access_token ^^^^^^^^^^^^^^^^^^^^^ File "/.../librespot-python/librespot/core.py", line 2301, in get_token response = self._session.mercury().send_sync_json( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/.../librespot-python/librespot/mercury.py", line 186, in send_sync_json raise MercuryClient.MercuryException(response) librespot.mercury.MercuryClient.MercuryException: status: 403 ``` It seems to happen after OAuth login, as a `credentials.json` file is created despite the error, and the error occurs without the OAuth callback if it's retried with the `credentials.json` file present. **To Reproduce** Steps to reproduce the behavior: 1. Run this code: ```python from librespot.core import Session session = Session.Builder().oauth(print).create() ``` 2. Paste the OAuth link into a browser and log in with a valid Spotify account 3. Watch the error happen after logging in **Expected behavior** The login is successful. **Client Information (please complete the following information):** - OS: Linux Mint 22.1 - Python Version: 3.12.3 - Library Version: The latest version from the repo
kerem 2026-02-27 08:11:40 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@wolkenschieber commented on GitHub (Sep 12, 2025):

Seeing the same with

self.session = Session.Builder().stored_file().create()

How did you solve this?

/cc @kokarare1212 as Ghost won't be able to reopen

NVM: Project dependency hick-up. Solved by:

pip uninstall librespot     
pip install git+https://github.com/kokarare1212/librespot-python@main
<!-- gh-comment-id:3284349021 --> @wolkenschieber commented on GitHub (Sep 12, 2025): Seeing the same with ```python self.session = Session.Builder().stored_file().create() ``` How did you solve this? /cc @kokarare1212 as _Ghost_ won't be able to reopen NVM: Project dependency hick-up. Solved by: ``` pip uninstall librespot pip install git+https://github.com/kokarare1212/librespot-python@main ```
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#57
No description provided.