I am using this code to get the userInfo
twitter = oauthtwitter.OAuthApi(CONSUMER_KEY, CONSUMER_SECRET, access_token)
try:
userinfo = twitter.GetUserInfo()
except:
# If we cannot get the user information, user cannot be authenticated
return None
screen_name = userinfo.screen_name
user, created 开发者_如何转开发= User.objects.get_or_create(username=screen_name)
here I am not able to get the email Id of the user so use another way that is tweety
import tweepy
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token("xxxxxxxxx", "yyyyyyyyyyyyyyy")
api = tweepy.API(auth)
Its also give me the same hash data and didnt provide me the email id of the user
Could any one please help me to get the Email id of the twitter user in Django app .
Thanks
Ansh J
Twitter's API does NOT give out the user's Email ID. This is by design.
(Side note: I had a similar requirement and found this out myself earlier)
I have filled out the xAuth form by giving the details of my app in here //support.twitter.com/forms/platform [I have added a youtube link for DEMO LINK and my app url in github for APPLICATION URL] and clicked on "submit" button.
Next,You will get 1st email from twitter(If you dont get an email from twitter,re-fill the form and send again) saying "Thanks for reaching out".Then after a few hours youll get a 2nd email saying that url app is whitelisted.
Once they say that your App is whitelisted, update your App's settings in Twitter Developer portal. Sign in to apps.twitter.com and:
On the 'Settings' tab, add a terms of service and privacy policy URL[which is must,try giving dummy url] On the 'Permissions' tab, change your token's scope to request email. This option will only been seen, once your App gets whitelisted.
Next,you may have to regenerate your access token in apps.twitter.com .And also use https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true in order to get the user's email address! It worked for me
精彩评论