1

我正在尝试通过 oauth2 Python 包将我的 Django 应用程序的用户身份验证到 Facebook。

def myView(request):

  consumer = oauth2.Consumer(
      key = settings.FACEBOOK_APP_ID,
      secret = settings.FACEBOOK_APP_SECRET)

  # Request token URL for Facebook.
  request_token_url = "https://www.facebook.com/dialog/oauth/"

  # Create client.
  client = oauth2.Client(consumer)

  # The OAuth Client request works just like httplib2 for the most part.
  resp, content = client.request(request_token_url, "GET")

  # Return a response that prints out the Facebook response and content.
  return HttpResponse(str(resp) + '\n\n ------ \n\n' + content)

但是,当我转到此视图时,我被定向到包含错误的页面。该错误有来自 Facebook 的此响应。

{'status': '200', 'content-length': '16418', 'x-xss-protection': '0',
 'content-location': u'https://www.facebook.com/dialog/oauth/?oauth_body_hash=2jmj7l5rSw0yVb%2FvlWAYkK%2FYBwk%3D&oauth_nonce=53865791&oauth_timestamp=1342666292&oauth_consumer_key=117889941688718&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_signature=XD%2BZKqhJzbOD8YBJoU1WgQ4iqtU%3D',
 'x-content-type-options': 'nosniff',
 'transfer-encoding': 'chunked',
 'expires': 'Sat, 01 Jan 2000 00:00:00 GMT',
 'connection': 'keep-alive',
 '-content-encoding': 'gzip',
 'pragma': 'no-cache',
 'cache-control': 'private, no-cache, no-store, must-revalidate',
 'date': 'Thu, 19 Jul 2012 02:51:33 GMT',
 'x-frame-options': 'DENY',
 'content-type': 'text/html; charset=utf-8',
 'x-fb-debug': 'yn3XYqMylh3KFcxU9+FA6cQx8+rFtP/9sJICRgj3GOQ='} 

有人在我的代码中看到任何错误吗?我尝试将参数连接为字符串,request_token_url但无济于事。我确信我的 Facebook 应用程序 ID 和密码字符串是正确的。

4

0 回答 0