我試圖按照步驟來獲得Facebook驗證在這裏提到http://developers.facebook.com/docs/authentication/devices/ 從用戶獲得認證。我執行下面的python腳本。嘗試使用python3.2
#!/usr/bin/python3.2
import os
import urllib
import json
data = urllib.parse.urlencode({'type': 'device_code','client_id': 439862919363245,'scope':})
data = data.encode('utf-8')
request = urllib.request.Request("https://graph.facebook.com/oauth/device")
request.add_header("Content-Type","application/json;charset=utf-8")
try:
response = urllib.request.urlopen(request,data)
httpcode = response.getcode()
responseData = response.read()
dataMap = json.loads(responseData.decode())
except Exception as e:
print ("Exception : "+str(e))
if httpcode != 200:
print('Error : code :'+httpcode+', data : '+data)
sys.exit(1)
print("Success : ")
print(dataMap)
我得到以下輸出:
Exception : HTTP Error 400: Bad Request
Success :
{'username': 'hamepal', 'first_name': 'Rakesh', 'last_name': 'Kumar', 'name': 'Rakesh Kumar', 'locale': 'en_GB', 'gender': 'male', 'id': '713371871'}
The output is really strange. According to document I should have received the data similar to as following.
{"code":"64a99b030985f39a93b2608a4713e758","user_code":"E5MV1N","verification_uri":"http://www.facebook.com/device","expires_in":1800,"interval":5}
我失去了一些東西在這裏?我也嘗試這裏 http://oauth-device-demo.appspot.com/給複製請求,但我不能得到任何成功。
我試圖尋找過網,但不能得到任何東西的工作。請幫忙。 這裏非常感謝任何幫助。
編輯: 現在,當我使用client_id相同的示例中給出,那麼它工作正常。根據網頁上的通知,似乎他們還沒有支持任何其他設備。我必須爲我的應用程序尋找認證流程。