Spotipy-设置CLIENT_ID和CLIENT_SECRET [英] Spotipy - set CLIENT_ID and CLIENT_SECRET

查看:236
本文介绍了Spotipy-设置CLIENT_ID和CLIENT_SECRET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪里设置CLIENT_ID和CLIENT_SECRET,使其不存储在我的python脚本中? Spotipy文档说明了以下内容,但是我无法弄清楚需要输入这些环境变量的位置.我在哪里设置os.getenv?

Where do I go to set CLIENT_ID and CLIENT_SECRET so it's not stored in my python script? The Spotipy documentation says the following, but I can't figure out where I need to go to input these environment variables. Where do I set os.getenv?

    if not client_id:
        client_id = os.getenv('SPOTIPY_CLIENT_ID')

    if not client_secret:
        client_secret = os.getenv('SPOTIPY_CLIENT_SECRET')

    if not client_id:
        raise SpotifyOauthError('No client id')

    if not client_secret:
        raise SpotifyOauthError('No client secret')

推荐答案

在Windows上,您可以设置环境变量以打开cmd,使用cd C:\example\example将目录更改为保存.py文件的目录,然后使用SET SPOTIPY_CLIENT_ID=clientIDhereSET SPOTIPY_CLIENT_SECRET=secretHere设置变量.

On windows you can set your enviroment variables openning your cmd, change your directory to where your .py file is saved using cd C:\example\example then use SET SPOTIPY_CLIENT_ID=clientIDhere and SET SPOTIPY_CLIENT_SECRET=secretHere to set your variables.

这篇关于Spotipy-设置CLIENT_ID和CLIENT_SECRET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆