2012-06-21 116 views
0

我正在使用django-socialregistration應用程序允許用戶通過FB登錄到我的網站。無法登錄Facebook(django-socialregistration)

http://django-socialregistration.readthedocs.org/en/latest/index.html 

Twitter並能正常工作,但對Facebook的它一直在以FB返回用戶登錄後此錯誤:

Credentials could not be validated, the provider returned no access token. 

它是在應用程序中設置一個錯誤在函數返回(附帶應用程序):

def get_access_token(self, code=None, **params): 
    """ 
    Return the memoized access token or go out and fetch one. 
    """ 
    if self._access_token is None: 
     if code is None: 
      raise ValueError(_('Invalid code.')) 

     self.access_token_dict = self._get_access_token(code, **params) 
     try: 
      self._access_token = self.access_token_dict['access_token'] 
     except KeyError, e: 
      raise OAuthError("Credentials could not be validated, the provider returned no access token.") 

所以我猜沒有訪問令牌可以找到或檢索。

Facebook的調試工具,雖然這時候我輸入的網址回報,

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC- html40/loose.dtd"> 
<html> 
<head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head> 
<body><p>Session expired.</p></body> 
</html> 

這是網址:

www.site.com/social/facebook/callback/?code=AQCb0lWCOTKFYaCQ43imfKvsMgo-8wyA8aq1WxZDWuCel2868I6gou2rn4bN2kTyuL14FxR9cCvrilJB2R5-JOnQqCvo7ihQAi9outrUB81MQdU-XA-5ur7MT5Wlhz3wkb5bc0fwzUYYFpSyeHNjFrIOY6QdZNdrXLcivv1-3qMNOKijLHf0jmZc7bBqPBTkw-Q#_=_ 

和響應代碼爲FB調試說是200

任何人都知道發生了什麼?

回答

0

這可能不是你的問題的解決方案,但它會產生更多的信息,以什麼是錯的。

改變上面的代碼到access_token_dict到標準輸出轉儲:

def get_access_token(self, code=None, **params): 
     """ 
     Return the memoized access token or go out and fetch one. 
     """ 
     if self._access_token is None: 
      if code is None: 
       raise ValueError(_('Invalid code.')) 

      self.access_token_dict = self._get_access_token(code, **params) 
      try: 
       self._access_token = self.access_token_dict['access_token'] 
      except KeyError, e: 
       print self.access_token_dict 
       raise OAuthError("Credentials could not be validated, the provider returned no access token.") 

socialregistration最常見的錯誤發生,由於在初始化和回調URL的不匹配 - 例如,你開始在http://localhost:8000和重定向回http://127.0.0.1:8000/*/callback/ Django將無法訪問您的localhost會話。

+0

你想讓我在git hub上打開一個問題也許它會更好嗎? – tamara

+0

我無法打印它,因爲我不在其開發本地版本上工作。 – tamara

+0

是的,在Github上打開一個問題可能會更好。 –

0

你必須去到你的應用程序高級設置(去http://developers.facebook.com並導航到你的應用項目 - >設置 - >高級)和你的服務器IP地址添加到白名單中。

我在這裏解決了這個問題。