I am trying to follow the steps mention here http://developers.facebook.com/docs/authentication/devices/
to get the authentication from user. I execute the following python script.
#!/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)
I get the following OutPut:
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}
Am I missing something here? I also try to replicate the request as given here
http://oauth-device-demo.appspot.com/ But I couldn’t get any success.
I tried to search over the net but couldn’t get any thing working. Please help.
Any kind of help is greatly appreciated here.
Edited:
Now when I use the client_id same as given in the example then it works fine. According to notice put on the page, seems like they are still not supporting any other device yet. And I have to look for Authentication flow for my application.
It’s actually pretty clear that you not white-listed for usage of Device Authentication.
Citing the docs
The OAuth 2.0 Device Authentication Flow demo you refer to developed by Simon Cross (who is Facebook employee) and (probably?) allowed to use that flow.