【问题标题】:Where do I put my environment variables for API credentials?我应该将 API 凭据的环境变量放在哪里?
【发布时间】:2016-11-09 01:54:20
【问题描述】:

我正在尝试使用 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

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

【问题讨论】:

    标签: python api spotify credentials


    【解决方案1】:

    我会开始here - Authorized Requests。然后你可以简单地使用这个例子:

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

    让事情开始,然后抓住你需要的东西。

    有关完整文档,请参阅 this page。并here 了解使用 SpotifyClientCredentials 的详细信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-04
      • 2015-04-18
      • 1970-01-01
      • 1970-01-01
      • 2018-08-16
      • 2018-11-12
      相关资源
      最近更新 更多