【问题标题】:python social auth get access_token not work in Flaskpython social auth get access_token在Flask中不起作用
【发布时间】:2015-07-14 04:23:29
【问题描述】:

我尝试像这样获取用户的 access_token:

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

但出现错误

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

我正在使用 Flask==0.10.1 和 python-social-auth==0.2.1(不希望更新)。
请帮我在烧瓶应用中接收用户的 access_token。

【问题讨论】:

    标签: python flask sqlalchemy flask-sqlalchemy python-social-auth


    【解决方案1】:

    通过查看文档,尝试将 .get 更改为 .filter

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

    【讨论】:

    • 不,绝对没有任何变化
    【解决方案2】:

    g.user.social_auth 是一个 SQLAlchemy 对象,所以你需要这样对待它。 @juzten 很接近。请尝试以下操作:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-23
      • 1970-01-01
      • 1970-01-01
      • 2020-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多