尝试在 Python 中进行身份验证以测试已注册的应用程序,按照“在没有 SoundCloud 连接屏幕的情况下进行身份验证”:http: //developers.soundcloud.com/docs/api/guide#user-credentials
import soundcloud
# create client object with app and user credentials
client = soundcloud.Client(client_id='YOUR_CLIENT_ID',
client_secret='YOUR_CLIENT_SECRET',
username='YOUR_USERNAME',
password='YOUR_PASSWORD')
该password='YOUR_PASSWORD'
行引发错误:
File "/usr/local/lib/python2.7/dist-packages/soundcloud/client.py", line 41, in __init__
self._credentials_flow()
File "/usr/local/lib/python2.7/dist-packages/soundcloud/client.py", line 112, in _credentials_flow
make_request('post', url, options))
File "/usr/local/lib/python2.7/dist-packages/soundcloud/resource.py", line 62, in wrapped_resource
setattr(result, attr, getattr(response, attr))
AttributeError: 'Response' object has no attribute 'error'
如果我将它包装在 a 中try:
,我会得到:
Error: 401 Client Error: None, Status Code: 401
我已经三重检查了 client_id 和 client_secret,我可以在网站上使用相同的凭据登录,并且我在代码中尝试了“用户名”和“用户名@email.com”格式。有任何想法吗?
[编辑:] 作为记录,“用户名”和“用户名@email.com”格式都有效。