有時當我嘗試登錄或與Facebook或谷歌註冊返回我一個錯誤AuthStateForbidden
屏幕Python的社會驗證顯示「AuthStateForbidden」有時
但就刷新頁面或之後再次嘗試同時,它運行正常。
我已經嘗試在Google開發者中添加Google+ API
,但與Facebook的問題相同。
有什麼想法?
在此先感謝!
有時當我嘗試登錄或與Facebook或谷歌註冊返回我一個錯誤AuthStateForbidden
屏幕Python的社會驗證顯示「AuthStateForbidden」有時
但就刷新頁面或之後再次嘗試同時,它運行正常。
我已經嘗試在Google開發者中添加Google+ API
,但與Facebook的問題相同。
有什麼想法?
在此先感謝!
我也有過幾次這個問題。從文檔,我們知道:
AuthStateForbidden - 服務器 返回的狀態參數不是 我已經尋找任何一種解決方法:用一個發送
class AuthStateForbidden(AuthException):
"""State parameter is incorrect."""
def __str__(self):
return 'Wrong state parameter given.'
沒有結果。另外我試圖以某種方式捕獲這個異常,但這是一個棘手的錯誤。我不知道如何重現它。
我已經在AuthStateForbidden
中搜索了python-social-auth的bug跟蹤器,正如我所說的 - 沒有任何東西。此外,目前有超過50個未解決的問題。無論如何,有可能創建一個new one。
這引發錯誤here:
def validate_state(self):
"""Validate state value. Raises exception on error, returns state
value if valid."""
if not self.STATE_PARAMETER and not self.REDIRECT_STATE:
return None
state = self.get_session_state()
request_state = self.get_request_state()
if not request_state:
raise AuthMissingParameter(self, 'state')
elif not state:
raise AuthStateMissing(self, 'state')
elif not request_state == state:
raise AuthStateForbidden(self)
從here(facebook.py
)調用:
@handle_http_errors
def auth_complete(self, *args, **kwargs):
"""Completes loging process, must return user instance"""
self.process_error(self.data)
if not self.data.get('code'):
raise AuthMissingParameter(self, 'code')
state = self.validate_state()
而在OAuthAuth
被創建的狀態下,它實現BaseAuth
並且是BaseOAuth
母體,其是FacebookOAuth
等的父親......幾乎不可能遵循此代碼。
我希望,guthub問題將在未來做到這一點。
感謝您的回覆和您的時間,我還在那裏創建了一個[issue](https://github.com/omab/python-social-auth/issues/627)(但關於其他主題)。我還沒有做任何事情來解決這個問題,但我沒有再看到它。但是我意識到避免錯誤屏幕的一種方法是編寫一個基於'middleware'的SocialAuthExceptionMiddleware'並捕獲異常。無論如何,我希望這個神祕的東西很快就能解決。 – Gocht