1

我正在尝试删除使用 None 值生成的 Spotify 访问令牌,该令牌在我的第二次连接尝试时中断。

我从这里得到了这个片段——> github thread,用于清除缓存的令牌:

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}")

我的令牌缓存在哪里?如何删除它以重新获得访问权限?

4

1 回答 1

1

缓存应存储在根目录(执行 python 文件的位置)的文件中。

它被命名为.cache-{username}。确保您打开了隐藏文件,否则您可能看不到它。

于 2017-08-02T22:31:02.247 回答