我试图按照步骤来获得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相同的示例中给出,那么它工作正常。根据网页上的通知,似乎他们还没有支持任何其他设备。我必须为我的应用程序寻找认证流程。