2016-11-09 49 views
1

我正在嘗試使用Spotify API,它需要客戶端憑據。我已經整合了spotipy,當我不需要請求用戶信息(即只是從藝術家下載曲目名稱),但我希望訪問音頻功能時,它工作正常。我在哪裏可以將我的環境變量用於API憑據?

在什麼文件/腳本和我如何包含憑據?

這是他們在oauth2.py文件說什麼:

You can either provid a client_id and client_secret to the 
    constructor or set SPOTIPY_CLIENT_ID and SPOTIPY_CLIENT_SECRET 
    environment variables 

https://github.com/plamere/spotipy/blob/master/examples/audio_features.py

回答

1

我將開始here - Authorized Requests。那麼你可以簡單地使用這個例子:

token = util.prompt_for_user_token(username) 
if token: 
    sp = spotipy.Spotify(auth=token) 

爲了開始,然後抓住你需要的東西。

有關完整文檔,請參閱this page。和here的詳細信息使用SpotifyClientCredentials

相關問題