samedi 22 mars 2014

404 error trying to use Facebook test user login_url


Vote count:

0




If I programmatically create a Facebook test user, the login_url for the new user doesn't work. Fetching the login_url returns a 404 error.


The sequence below used to work fine; it seems to have become broken in the past month or so.


Pared-down example (in Python). The last two lines are where the problem shows up:



import requests
from urlparse import parse_qs
APP_ID = "<Facebook App ID>"
APP_SECRET = "<Facebook Client Secret>"

# Get app access token - this works
response = requests.get('http://ift.tt/JH6Whd',
params={'grant_type': "client_credentials",
'client_id': APP_ID, 'client_secret': APP_SECRET})
app_access_token = parse_qs(response.content)['access_token'][0]

# Create test user - this works
response = requests.post('http://ift.tt/147ORMQ' % APP_ID,
data={'access_token': app_access_token, 'installed': "true"})
test_user = response.json()
login_url = test_user['login_url']
print login_url # http://ift.tt/1oLZWiV...

# Get cookied for login - see http://ift.tt/1oLZXmX
session = requests.Session()
session.get("http://ift.tt/g8FRpY", allow_redirects=True)

# Login test user - THIS FAILS
response = session.get(login_url)
print response.status_code # 404


Others have noted that you must first fetch the Facebook homepage before test user's login_url will work. We ran into that same problem, and I've included that workaround above without any luck.


I also tried opening the login_url directly in a browser:



  • If I'm not already logged into Facebook, I get a generic Facebook 404 page.

  • If I'm already logged into my developer account, Facebook warns that I'll be logged in as a platform test user, and then allows me into the test user's account.


That last point seems to confirm that the test user is being created properly and that I have the correct login_url. But of course, that's no help for automated testing. (We don't want to run tests logged into my developer account.)


Is there some other way the test user's login_url is meant to be used for automated testing?



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire