python-social-auth icon indicating copy to clipboard operation
python-social-auth copied to clipboard

Grab user's Email during authentication with Twitter

Open halfstrik opened this issue 10 years ago • 5 comments

Greetings!

I perform a little googling and find out that Twitter recently adds optional returning of users Email address. Look at the end of this long thread and Twitter docs.

In short, if your app is approved by Twitter and you provide links to ToS and Privacy Policy for your site, you can (as they claim) get a user email address by providing include_email in request to endpoint https://api.twitter.com/1.1/account/verify_credentials.json.

Does any one succeed at this? Any thoughts?

halfstrik avatar Jan 22 '16 19:01 halfstrik

I submitted a request to Twitter asking for more user details (including e-mail) for my app. They approved, I changed social-auth's parameters and I am still unable to get the e-mail in the request. It would be interesting to know if someone succeeded in this.

evcb avatar Jan 25 '16 00:01 evcb

I managed to get it right and actually receive user email!

For this several steps need to be done (see this post)

Make sure Twitter respond to you via email and approved that your app actually get white-listed.

Than this changes need to be done in python-social-auth app in python/lib/python2.7/site-packages/social/backends/twitter.py: line 30: 'email': response.get('email'), line 38: 'https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true',

In other words, Parameters from Twitter documentation must go not to access_token object, but rather to URL as path params.

I'll try to create a pull request for this as soon as I understand how this app works on examples with Facebook and similar.

halfstrik avatar Jan 27 '16 10:01 halfstrik

It worked, @halfstrik. It should be fixed in the app and updated in the documentation.

evcb avatar Jan 28 '16 13:01 evcb

@hellvix, great to hear it! I updated appropriate docs/ files in this PR as well.

The things I'm unsure are the name of the variable in settings and a quality of my test. Will wait @omab for judgments:)

halfstrik avatar Jan 28 '16 13:01 halfstrik

Fix already merged, thanks!

omab avatar Dec 26 '16 15:12 omab