我正在尝试删除使用 None 值生成的 Spotify 访问 token ,该 token 在我第二次连接尝试时中断。
我从这里得到了这个片段 --> github thread ,用于清除缓存的token:
import os
from json.decoder import JSONDecodeError
scope = <whatever_youwant>
try:
token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)
except (AttributeError, JSONDecodeError):
os.remove(f".cache-{username}")
token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)
但我在这里遇到语法错误:
os.remove(f".cache-{username}")
我的 token 缓存在哪里?我怎样才能删除它以重新获得访问权限?
最佳答案
缓存应存储在根目录(Python 文件执行的位置)的文件中。
它的名称为.cache-{username}
。确保您已打开隐藏文件,否则您可能看不到它。
关于python - Spotify - 删除使用 None 值创建的访问 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45471960/