2016-11-09 57 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

相关问题