Несанкционированная ошибка URL при изменении воспроизведения песен - PullRequest
0 голосов
/ 15 июня 2019

Я пытаюсь контролировать воспроизведение моей музыки с помощью спотипа.При попытке сделать паузу или вернуться к предыдущему треку я получаю 401 ошибку.Я подозреваю, что проблема связана с авторизацией spotify для требуемой области для воспроизведения?

Я пытался включить в свой запрос на авторизацию область потоковой передачи и область действия пользователя-изменения-воспроизведения-состояния, но обепривело к ошибкам.

scope = "streaming user-modify-playback-state user-read-currently-playing"
username = "my username"
clientId = "my client id"
clientSecret = "my client secret"
redirect_url = "https://localhost/"
sp = spotipy.Spotify()

def permission():
    token = util.prompt_for_user_token(username, scope, client_id=clientId, client_secret=clientSecret, redirect_uri=redirect_url)           
    return token

def main():
    token = permission()
    if token:
        sp.previous_track();
main()

Вот сообщение:

Traceback (most recent call last):
File "C:\Users\Naveen\PycharmProjects\SpotipyTest\venv\lib\site-  packages\spotipy\client.py", line 121, in _internal_call
r.raise_for_status()
File "C:\Users\Naveen\PycharmProjects\SpotipyTest\venv\lib\site- packages\requests\models.py", line 940, 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/previous
...