如何解决获取 spotipy.oauth2.SpotifyOauthError:spotipy api:sp.current_user() 错误
我正在使用 spotipy API,但出现错误。
这是代码:
import spotipy
from spotipy.oauth2 import SpotifyOAuth
sp = spotipy.Spotify(
auth_manager=SpotifyOAuth(
scope="playlist-modify-private",redirect_uri="http://example.com",client_id="90f1208cc6a04264a556a1c2331ec29b",client_secret="08be269ec22042de8d571d922f7f9434",show_dialog=True,cache_path="token.txt"
)
)
user_id = sp.current_user()["id"]
这是错误:
Traceback (most recent call last):
File "C:/Users/kendrashya/Desktop/workspace/100DaysOfPython/Day-46-Start/main2.py",line 15,in <module>
user_id = sp.current_user()["id"]
File "C:\Users\kendrashya\AppData\Local\Programs\Python\Python38-32\lib\site-packages\spotipy\client.py",line 1167,in current_user
return self.me()
File "C:\Users\kendrashya\AppData\Local\Programs\Python\Python38-32\lib\site-packages\spotipy\client.py",line 1161,in me
return self._get("me/")
File "C:\Users\kendrashya\AppData\Local\Programs\Python\Python38-32\lib\site-packages\spotipy\client.py",line 291,in _get
return self._internal_call("GET",url,payload,kwargs)
File "C:\Users\kendrashya\AppData\Local\Programs\Python\Python38-32\lib\site-packages\spotipy\client.py",line 221,in _internal_call
headers = self._auth_headers()
File "C:\Users\kendrashya\AppData\Local\Programs\Python\Python38-32\lib\site-packages\spotipy\client.py",line 212,in _auth_headers
token = self.auth_manager.get_access_token(as_dict=False)
File "C:\Users\kendrashya\AppData\Local\Programs\Python\Python38-32\lib\site-packages\spotipy\oauth2.py",line 506,in get_access_token
raise SpotifyOauthError(
spotipy.oauth2.SpotifyOauthError: error: invalid_grant,error_description: Invalid authorization code
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。