[GH-ISSUE #259] Propagate error from couldn't refresh token #140

Closed
opened 2026-02-27 23:21:02 +03:00 by kerem · 0 comments
Owner

Originally created by @loisaidasam on GitHub (Feb 20, 2018).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/259

If you call refresh_access_token(), and the response is anything other than a 200, it will print the response code and failure reason to stderr, and then return None.

Source:

github.com/plamere/spotipy@4c2c1d763a/spotipy/oauth2.py (L239-L245)

This leaves the caller totally in the dark as to why the token refresh failed! What if Spotify's API had some intermittent outage? Maybe it was a bad request? Maybe something else?! How is the caller to know?

I propose either calling Requests' raise_for_status() or throwing some other sort of custom exception that passes either the entire response, or at least the error code and reason.

Thoughts?

Originally created by @loisaidasam on GitHub (Feb 20, 2018). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/259 If you call `refresh_access_token()`, and the response is anything other than a `200`, it will print the response code and failure reason to `stderr`, and then return `None`. Source: https://github.com/plamere/spotipy/blob/4c2c1d763a3653aa225c4af848409ec31286a6bf/spotipy/oauth2.py#L239-L245 This leaves the caller totally in the dark as to why the token refresh failed! What if Spotify's API had some intermittent outage? Maybe it was a bad request? Maybe something else?! How is the caller to know? I propose either calling Requests' [raise_for_status()](http://docs.python-requests.org/en/master/api/#requests.Response.raise_for_status) or throwing some other sort of custom exception that passes either the entire response, or at least the error code and reason. Thoughts?
kerem closed this issue 2026-02-27 23:21:03 +03:00
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/spotipy#140
No description provided.