Skip to content

[BUG] 429: API rate limit exceeded when using tokens with Spotify API #328

Description

@malmeloo

Describe the bug
Using session.tokens().get_token(...) to generate tokens for the Spotify Web API seems to not work anymore, as requests using these tokens always result in a 429 response, even though rate limits are not actually being hit (fresh IP, fresh account, works on desktop and works with a known valid token).

To Reproduce
Example with /me/tracks given a session:

    token = session.tokens().get_token(
        "user-read-email",
        "playlist-read-private",
        "user-library-read",
        "user-follow-read",
    )
    headers = {
        "Authorization": f"Bearer {token.access_token}",
    }
    params = {
        "limit": 50,
        "offset": 0
    }

    r = httpx.get(url, headers=headers, params=params)
    print(r.json())
    r.raise_for_status()

Returns:

{'error': {'status': 429, 'message': 'API rate limit exceeded'}}

Expected behavior
A proper response from the API. If you swap out the token above for one obtained from Spotify themselves (e.g. by intercepting a network request while testing an endpoint on the developer website), the request succeeds.

Client Information (please complete the following information):

  • OS: Linux (NixOS 25.11)
  • Python Version: 3.12.8
  • Library Version: latest commit (dafd539)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions