Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在哪里放置API凭据的环境变量?_Python_Api_Spotify_Credentials - Fatal编程技术网

Python 在哪里放置API凭据的环境变量?

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

我正在尝试使用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_SECRET
    environment variables
我要开始了。然后,您可以简单地使用以下示例:

token = util.prompt_for_user_token(username)
if token:
    sp = spotipy.Spotify(auth=token)
开始工作,然后抓住你需要的东西

有关完整文档,请参阅。有关详细信息,请使用SpotifyClientCredentials