我正在尝试在PythonAnywhere上部署我的应用程序,但我无法设置Flask-Stormpath Facebook登录。
基于电子邮件的登录和Google连接工作正常,但Facebook登录无效。我已将Facebook应用程序更新为正确的应用程序URL,并验证Facebook连接是否可以在localhost上运行。
2016-04-14 18:08:07,121 :Exception on /facebook [GET]
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1687, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1360, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1358, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1344, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/btpraasta/.local/lib/python2.7/site-packages/flask_stormpath/views.py", line 265, in facebook_login
current_app.config['STORMPATH_SOCIAL']['FACEBOOK']['app_secret'],
File "/usr/local/lib/python2.7/dist-packages/facebook.py", line 497, in get_user_from_cookie
app_id, app_secret)
File "/usr/local/lib/python2.7/dist-packages/facebook.py", line 581, in get_access_token_from_code
response = json.loads(response)
File "/usr/local/lib/python2.7/dist-packages/simplejson/__init__.py", line 488, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python2.7/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/local/lib/python2.7/dist-packages/simplejson/decoder.py", line 389, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
以下是我正在使用的StormPath的配置: -
# Stormpath app configuration
app.config['STORMPATH_API_KEY_FILE'] = '/home/btpraasta/btp_raasta/stormpath/apiKey.properties'
app.config['STORMPATH_API_KEY_FILE'] = 'stormpath/apiKey.properties'
app.config['STORMPATH_APPLICATION'] = 'Raasta'
app.config['STORMPATH_REDIRECT_URL'] = '/redirecting'
app.config['STORMPATH_REGISTRATION_REDIRECT_URL'] = '/verifyEmail'
app.config['STORMPATH_REGISTRATION_TEMPLATE'] = 'register.html'
app.config['STORMPATH_LOGIN_TEMPLATE'] = 'login.html'
app.config['STORMPATH_FORGOT_PASSWORD_TEMPLATE'] = 'forgot.html'
app.config['STORMPATH_ENABLE_MIDDLE_NAME'] = False
app.config['STORMPATH_ENABLE_USERNAME'] = True
app.config['STORMPATH_REQUIRE_USERNAME'] = True
app.config['STORMPATH_ENABLE_FORGOT_PASSWORD'] = True
app.config['STORMPATH_ENABLE_FACEBOOK'] = True
app.config['STORMPATH_ENABLE_GOOGLE'] = True
app.config['STORMPATH_SOCIAL'] = {
'FACEBOOK': {
'app_id': 'xxxxx',
'app_secret': 'xxxxx',
},
'GOOGLE': {
'client_id': 'xxxxx',
'client_secret': 'xxxxxx',
}
}
已隐藏client_id和client_secret。相同的配置适用于localhost。
答案 0 :(得分:1)
该错误是由于Facebook-SDK版本0.4没有输出代理支持。提出了一个问题,现在Flask-Stormpath使用支持相同的Facebook-SDK 1.0版。
如果您仍然面临同样的问题,请更新您的Flask-Stormpath: -
pip install --upgrade flask-stormpath