hudo
hudo

Reputation: 11

python social auth get access_token not work in Flask

I try get user's access_token like this way:

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).
Help me receive user's access_token in flask app please.

Upvotes: 1

Views: 142

Answers (2)

Kevin Fink
Kevin Fink

Reputation: 151

g.user.social_auth is a SQLAlchemy object, so you need to treat it as such. @juzten was close. Try the following:

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

Upvotes: 1

juzten
juzten

Reputation: 154

From looking at the docs, try changing .get to .filter

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

Upvotes: 0

Related Questions