[GH-ISSUE #657] Permissions missing, reason: None #390

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

Originally created by @joebonneau on GitHub (Mar 22, 2021).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/657

Hello there,

I am trying to run the following block of code:

import spotipy
from spotipy.oauth2 import SpotifyClientCredentials, SpotifyOAuth

scope = "user-read-currently-playing"

sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
playback = sp.current_playback()
print(playback)

and keep running into the following error:

HTTP Error for GET to https://api.spotify.com/v1/me/player returned 401 due to Permissions missing
Traceback (most recent call last):
File "/home/joe-linux/.pyenv/versions/venv-spotifriend/lib/python3.9/site-packages/spotipy/client.py", line 245, in _internal_call
response.raise_for_status()
File "/home/joe-linux/.pyenv/versions/venv-spotifriend/lib/python3.9/site-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.spotify.com/v1/me/player

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/joe-linux/Documents/GitHub Repos/spotifriend/.code/interface.py", line 14, in
playback = sp.current_playback()
File "/home/joe-linux/.pyenv/versions/venv-spotifriend/lib/python3.9/site-packages/spotipy/client.py", line 1645, in current_playback
return self._get("me/player", market=market, additional_types=additional_types)
File "/home/joe-linux/.pyenv/versions/venv-spotifriend/lib/python3.9/site-packages/spotipy/client.py", line 291, in _get
return self._internal_call("GET", url, payload, kwargs)
File "/home/joe-linux/.pyenv/versions/venv-spotifriend/lib/python3.9/site-packages/spotipy/client.py", line 261, in _internal_call
raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 401, code:-1 - https://api.spotify.com/v1/me/player:
Permissions missing, reason: None

I can't quite figure out what permissions are missing for this method call - I have SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET, and SPOTIPY_REDIRECT_URI set as environment variables.

Thanks in advance!

Originally created by @joebonneau on GitHub (Mar 22, 2021). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/657 <!--- Please make sure you've: - read the FAQ https://github.com/plamere/spotipy/blob/master/FAQ.md - read the documentation https://spotipy.readthedocs.io/en/latest/ - searched older issues If your question is about code, please share the code you are using ---> Hello there, I am trying to run the following block of code: > import spotipy > from spotipy.oauth2 import SpotifyClientCredentials, SpotifyOAuth > > scope = "user-read-currently-playing" > > sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope)) > playback = sp.current_playback() > print(playback) and keep running into the following error: > HTTP Error for GET to https://api.spotify.com/v1/me/player returned 401 due to Permissions missing > Traceback (most recent call last): > File "/home/joe-linux/.pyenv/versions/venv-spotifriend/lib/python3.9/site-packages/spotipy/client.py", line 245, in _internal_call > response.raise_for_status() > File "/home/joe-linux/.pyenv/versions/venv-spotifriend/lib/python3.9/site-packages/requests/models.py", line 943, in raise_for_status > raise HTTPError(http_error_msg, response=self) > requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.spotify.com/v1/me/player > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > File "/home/joe-linux/Documents/GitHub Repos/spotifriend/.code/interface.py", line 14, in <module> > playback = sp.current_playback() > File "/home/joe-linux/.pyenv/versions/venv-spotifriend/lib/python3.9/site-packages/spotipy/client.py", line 1645, in current_playback > return self._get("me/player", market=market, additional_types=additional_types) > File "/home/joe-linux/.pyenv/versions/venv-spotifriend/lib/python3.9/site-packages/spotipy/client.py", line 291, in _get > return self._internal_call("GET", url, payload, kwargs) > File "/home/joe-linux/.pyenv/versions/venv-spotifriend/lib/python3.9/site-packages/spotipy/client.py", line 261, in _internal_call > raise SpotifyException( > spotipy.exceptions.SpotifyException: http status: 401, code:-1 - https://api.spotify.com/v1/me/player: > Permissions missing, reason: None I can't quite figure out what permissions are missing for this method call - I have SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET, and SPOTIPY_REDIRECT_URI set as environment variables. Thanks in advance!
kerem 2026-02-27 23:22:21 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@joebonneau commented on GitHub (Mar 22, 2021):

I'm realizing that maybe it's because I don't have a user specified, but I also don't see where to specify that.

<!-- gh-comment-id:803748178 --> @joebonneau commented on GitHub (Mar 22, 2021): I'm realizing that maybe it's because I don't have a user specified, but I also don't see where to specify that.
Author
Owner

@joebonneau commented on GitHub (Mar 22, 2021):

Looks like I needed to use util.prompt_for_user_token instead of what I tried. Sorry for the spam and quick close!

<!-- gh-comment-id:803751125 --> @joebonneau commented on GitHub (Mar 22, 2021): Looks like I needed to use `util.prompt_for_user_token` instead of what I tried. Sorry for the spam and quick close!
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#390
No description provided.