2012-12-18 60 views
0

试图在Python“未经的SoundCloud连接屏幕身份验证”来验证测试的注册的应用程序,按照: http://developers.soundcloud.com/docs/api/guide#user-credentials的SoundCloud API返回服务器端的Python认证401错误

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' 

如果我在try:包装它,我得到:

Error: 401 Client Error: None, Status Code: 401 

我已经三重检查了client_id和client_secret,我可以在网站上使用相同的凭据登录,并且我已经在代码中尝试了“用户名”和“[email protected]”格式。有任何想法吗?

[编辑:]记录,'用户名'和'[email protected]'格式的工作。

+0

尝试将'requests'降级到版本0.14.2。我怀疑'soundcloud'如果b0rken for'requests'版本1.0.0及以上。 –

回答

3

您必须将requests库降级到版本0.14.2。

soundcloud API python库封装了requests.models.Response对象,并且对于版本1.0.0的重构,.error属性被删除。但是仍然期望它在那里。

我建议你使用virtualenv来安装库。您可以手动从virtualenv中删除requests库,或使用pip降级它:

pip install -I requests==0.14.2 

您可能希望将此问题报告给了soundcloud-python code project,使他们可以解决他们的setup.py依赖或修复库工作与requests 1.0.0或更新。

+0

立即成功。惊人。好样的! – meetar

+0

问题报告。 – meetar

相关问题