0
設置證書
我試圖運行從Spotipy文檔一些簡單的代碼:麻煩Spotipy
scope = 'user-library-read'
if len(sys.argv) > 1:
username = sys.argv[1]
else:
print ("Usage: %s username" % (sys.argv[0],))
sys.exit()
token = util.prompt_for_user_token(username, scope)
我已經嘗試過通過運行來建立我的憑證在我的終端(Ubuntu的):
$ export SPOTIPY_CLIENT_ID='[my id]'
$ export SPOTIPY_CLIENT_SECRET='[my secret]'
$ export SPOTIPY_REDIRECT_URI='localhost:8888/callback'
不過,我得到這個:
You need to set your Spotify API credentials. You can do this by
setting environment variables like so:
export SPOTIPY_CLIENT_ID='your-spotify-client-id'
export SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'
export SPOTIPY_REDIRECT_URI='your-app-redirect-url'
Get your credentials at
https://developer.spotify.com/my-applications
---------------------------------------------------------------------------
SpotifyException Traceback (most recent call last)
<ipython-input-13-e24370a9caf8> in <module>()
7 sys.exit()
8
----> 9 token = util.prompt_for_user_token(username, scope)
/home/arvcondor/anaconda3/envs/Python3/lib/python3.6/site-packages/spotipy/util.py in prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)
45 https://developer.spotify.com/my-applications
46 ''')
---> 47 raise spotipy.SpotifyException(550, -1, 'no credentials set')
48
49 sp_oauth = oauth2.SpotifyOAuth(client_id, client_secret, redirect_uri,
SpotifyException: http status: 550, code:-1 - no credentials set
我在做什麼錯?我一直無法找到如何解決這個問題的簡潔流程。
在此先感謝您的幫助。
'$ export SPOTIPY_REDIRECT_URI ='ocalhost:8888/callback'' ....'ocalhost'? –
這是一個錯字,對不起,編輯 – snapcrack
嘗試直接在python中定義憑證:'util.prompt_for_user_token(username,scope,client_id,client_secret,redirect_uri)' – sKwa