2012-12-18 57 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

相關問題