0
我很努力地獲得OAuth2授權,以處理我在EC2 Linux服務器實例(運行Ubuntu 13.04)上運行它時處理的腳本。有關片段是:爲什麼OAuth2身份驗證在家庭計算機上工作,但不在服務器上工作?
with open('creds.txt') as f:
creds = {}
for line in f:
creds[line.split(',')[0]] = line.split(',')[1].rstrip('\n')
self.client_id = creds['client_id']
self.client_secret = creds['client_secret']
self.username = creds['username']
self.password = creds['password'])
token_response = requests.post(
"https://example.com/oauth2/access_token/",
data={
"grant_type": "password",
"client_id": self.client_id,
"client_secret": self.client_secret,
"username": self.username,
"password": self.password,
"scope": "read+write"}).json()
它運行我家的電腦(運行Windows 7)的罰款,只是沒有當我嘗試遠程運行它,我得到:{u'error': u'invalid_client'}
。
我試過設置一個新的客戶端ID和密碼,仍然得到相同的響應。
- 爲什麼它在遠程服務器上對我自己的機器有不同的作用?
-
這對創建應用程序的機器有影響嗎(請參閱評論)?- 我通過在兩種環境中使用CURL
成功驗證來消除了這種可能性。
我現在唯一能想到的是,可能請求庫在Ubuntu上處理POST請求的方式不同。有誰知道這是否是這種情況?
[This answer](http://stackoverflow.com/a/11267728/1706564)似乎可能相關,因爲它表明客戶端ID關心它生成的操作系統。儘管如此,我無法在[文檔](http://tools.ietf.org/html/rfc6749)中找到任何證據。 –