Python 在哪里放置API凭据的环境变量?
我正在尝试使用Spotify API,它需要客户端凭据。我集成了spotipy,当我不需要请求用户信息(即从艺术家那里下载曲目名称)但我希望访问音频功能时,它可以正常工作 在什么文件/脚本中以及如何包含凭据 这是他们在oauth2.py文件中所说的:Python 在哪里放置API凭据的环境变量?,python,api,spotify,credentials,Python,Api,Spotify,Credentials,我正在尝试使用Spotify API,它需要客户端凭据。我集成了spotipy,当我不需要请求用户信息(即从艺术家那里下载曲目名称)但我希望访问音频功能时,它可以正常工作 在什么文件/脚本中以及如何包含凭据 这是他们在oauth2.py文件中所说的: You can either provid a client_id and client_secret to the constructor or set SPOTIPY_CLIENT_ID and SPOTIPY_CLIENT_S
You can either provid a client_id and client_secret to the
constructor or set SPOTIPY_CLIENT_ID and SPOTIPY_CLIENT_SECRET
environment variables
我要开始了。然后,您可以简单地使用以下示例:
token = util.prompt_for_user_token(username)
if token:
sp = spotipy.Spotify(auth=token)
开始工作,然后抓住你需要的东西
有关完整文档,请参阅。有关详细信息,请使用SpotifyClientCredentials