简体   繁体   English

python social auth get access_token在Flask中不起作用

[英]python social auth get access_token not work in Flask

I try get user's access_token like this way: 我尝试以这种方式获取用户的access_token:

social = g.user.social_auth.get(provider='twitter')
token = social.extra_data['access_token']

but get error 但出现错误

TypeError: get() got an unexpected keyword argument 'provider'

I'm use Flask==0.10.1 and python-social-auth==0.2.1 (update is not desirable). 我使用Flask == 0.10.1和python-social-auth == 0.2.1(不希望进行更新)。
Help me receive user's access_token in flask app please. 请帮助我在flask应用程序中接收用户的access_token。

从查看文档开始,尝试将.get更改为.filter

social = g.user.social_auth.filter(provider='twitter')

g.user.social_auth is a SQLAlchemy object, so you need to treat it as such. g.user.social_auth是一个SQLAlchemy对象,因此您需要将其视为此类。 @juzten was close. @juzten很近。 Try the following: 请尝试以下操作:

social = g.user.social_auth.filter_by(provider='twitter').first() 社交= g.user.social_auth.filter_by(provider ='twitter')。first()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM