我正在尝试使用他们的Python 客户端库访问Discogs API。
这是我尝试与 Discogs API 交互的一个最小示例:
from SensitiveInformation.discogs_application_info import provide_discogs_auth, provide_verifier
import discogs_client
discogs_consumer_key, discogs_consumer_secret = provide_discogs_auth()
discogs = discogs_client.Client(user_agent="ThoughfulMachineLearning",
consumer_key=discogs_consumer_key,
consumer_secret=discogs_consumer_secret)
discogs_auth_url = discogs.get_authorize_url()
discogs.get_access_token(verifier=provide_verifier())
discogs.identity()
函数provide_discogs_auth
和provide_verifier
简单地从用户授权中返回消费者密钥和秘密以及验证者。get_access_token
按预期返回访问密钥和秘密。
但是,在最后一行,当我进行 API 调用时,我得到:
Out[38]: In[39]: discogs.identity()
Traceback (most recent call last):
Out[39]: File "/usr/local/lib/python3.4/dist-packages/IPython/core/formatters.py", line 219, in catch_format_error
r = method(self, *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/IPython/core/formatters.py", line 690, in __call__
printer.pretty(obj)
File "/usr/local/lib/python3.4/dist-packages/IPython/lib/pretty.py", line 407, in pretty
return _default_pprint(obj, self, cycle)
File "/usr/local/lib/python3.4/dist-packages/IPython/lib/pretty.py", line 527, in _default_pprint
_repr_pprint(obj, p, cycle)
File "/usr/local/lib/python3.4/dist-packages/IPython/lib/pretty.py", line 709, in _repr_pprint
output = repr(obj)
TypeError: __repr__ returned non-string (type bytes)
不确定这是否与 IPython 或客户端库有关,但无论哪种方式都将不胜感激。谢谢。