2016-07-17 4 views
1

Ich versuche Social Login in Flask mit Python-Social-Auth zu implementieren. Es funktioniert in der Entwicklung auf localhost, aber nicht in der Produktion.Fehler bei der Umleitung von Facebook Login mit Python-Social-Auth, SqlAlchemy und Flask

Der Fehler tritt bei der Umleitung von der Anmeldung mit Facebook auf. Nach dem Debuggen scheint es durch Dekodierung in sql type pickle oder json verursacht worden zu sein. Ich habe in das Modul json gegraben, aber ich habe keine Ahnung, wie ich es reparieren soll, und ich denke, es sollte dort nicht repariert werden, da es ein eingebautes Modul ist.

Warum funktioniert Facebook Login in der Entwicklung auf localhost, aber nicht in der Produktion?

Exception on /complete/facebook/ [GET] 
Traceback (most recent call last): 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app 
    response = self.full_dispatch_request() 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request 
    rv = self.handle_user_exception(e) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception 
    reraise(exc_type, exc_value, tb) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request 
    rv = self.dispatch_request() 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request 
    return self.view_functions[rule.endpoint](**req.view_args) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/social/apps/flask_app/utils.py", line 46, in wrapper 
    return func(backend, *args, **kwargs) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/social/apps/flask_app/routes.py", line 23, in complete 
    *args, **kwargs) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/social/actions.py", line 43, in do_complete 
    user = backend.complete(user=user, *args, **kwargs) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/social/backends/base.py", line 41, in complete 
    return self.auth_complete(*args, **kwargs) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/social/utils.py", line 229, in wrapper 
    return func(*args, **kwargs) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/social/backends/facebook.py", line 87, in auth_complete 
    return self.do_auth(access_token, response, *args, **kwargs) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/social/backends/facebook.py", line 119, in do_auth 
    return self.strategy.authenticate(*args, **kwargs) 
File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/social/backends/base.py", line 82, in authenticate 
    return self.pipeline(pipeline, *args, **kwargs) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/social/backends/base.py", line 85, in pipeline 
    out = self.run_pipeline(pipeline, pipeline_index, *args, **kwargs) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/social/backends/base.py", line 112, in run_pipeline 
    result = func(*args, **out) or {} 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/social/pipeline/social_auth.py", line 20, in social_user 
    social = backend.strategy.storage.user.get_social_auth(provider, uid) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/social/storage/sqlalchemy_orm.py", line 136, in get_social_auth 
    uid=uid)[0] 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2462, in __getitem__ 
    return list(self[item:item + 1])[0] 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2457, in __getitem__ 
    return list(res) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 86, in instances 
    util.raise_from_cause(err) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 200, in raise_from_cause 
    reraise(type(exception), exception, tb=exc_tb, cause=cause) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 71, in instances 
    rows = [proc(row) for row in fetch] 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 428, in _instance 
    loaded_instance, populate_existing, populators) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 486, in _populate_full 
    dict_[key] = getter(row) 
    File "/home/dev/huugbaan/xxvenv/lib/python2.7/site-packages/sqlalchemy/sql/sqltypes.py", line 1258, in process 
    return loads(value) 
    File "/usr/local/lib/python2.7.12/lib/python2.7/json/__init__.py", line 339, in loads 
    return _default_decoder.decode(s) 
    File "/usr/local/lib/python2.7.12/lib/python2.7/json/decoder.py", line 364, in decode 
    obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 
TypeError: expected string or buffer 
[pid: 5053|app: 0|req: 6/26] 171.99.3.44() {42 vars in 1892 bytes} [Sun Jul 17 02:09:00 2016] GET /complete/facebook/?redirect_state=i2C8teuxp7n3o39bhzK8Ypwa8S2O1EzC&code=AQBim0qoaEqukud-ysEQpuhyhy63v729wxqQ5qo3HTYRFSerzQrCgjXVKUu-EA1A1A5CXbAfzvZHb87K4moaxt0Wk4g5mhQQQ--ovb9NygFUybyznSk-09O8x-zB5CXSyFVR-fDV54CXSNbhBOJJvPWQu9rJ0QlGj53kEDFyKCgXA0-gHyLIXfDveY-3Z_nouWv0mosSogs9JSE06EQ9ZfZh87HKJkihEcnAs_QhO3eHhkZ5uqf7ZSWc-Soj2c4XXVEG38aR5Ltl-cv7tWkwAsKFtW36nBcF0NzEhDiuSYaiTIn-nZBnRBveO7PFrDJRj6GEts1tc9pY29KnZuA72YwN&state=i2C8teuxp7n3o39bhzK8Ypwa8S2O1EzC => generated 4571 bytes in 587 msecs (HTTP/1.1 500) 2 headers in 100 bytes (1 switches on core 0) 

Antwort

0

tun nur schmutzig fix bei sqltype.py von sqlalchemy Paket nach dem Debuggen. Ich habe den Unterschied des Werttyps in der Methode unten herausgefunden. Also habe ich beschlossen, den Wert zu überspringen und zurückzugeben, wenn es bereits dict ist.

1245  def result_processor(self, dialect, coltype): 
1246   impl_processor = self.impl.result_processor(dialect, coltype) 
1247   loads = self.pickler.loads 
1248   if impl_processor: 
1249    def process(value): 
1250     value = impl_processor(value) 
1251     if value is None: 
1252      return None 
1253     return loads(value) 
1254   else: 
1255    def process(value): 
1256     if value is None: 
1257      return None 
#### ->>>   if type(value) is dict: return value 
1258     return loads(value) 
1259   return process 

if type(value) is dict: return value in Zeile 1258

Verwandte Themen