How to get user email after app is whitelisted to request email address

email

#1

We are following the instruction from this url:
https://dev.twitter.com/rest/reference/get/account/verify_credentials

my app is white listed for “Request email addresses from users” but we are not getting user email address.


#2

Check the following:

  • you’ve added a privacy policy and terms of service url in your app settings
  • you’ve added the permission to request email address on the Permissions tab in your app settings
  • you’ve saved the changes to your app settings :grinning:
  • you have a newly authenticated user token - an existing user token will continue to have the old permissions, so you will not be able to retrieve an email. If you need to do that, either recycle your app keys, or otherwise discard the user token and force the user to login again
  • the user is prompted for permission to share email address on authentication, and grants it to the app
  • the user account has a verified email address i.e. they have both added an email to the account, and responded to the challenge email sent by Twitter on sign-up to verify the email address
  • you’re including ?include_email=true on your call to verify_credentials

If you have checked all of those, please share some example code (excluding secret application tokens and keys) and any response codes from the Twitter API.


#3

Following request or response code get from "https://dev.twitter.com/rest/tools/console"
REQUEST

GET /1.1/account/verify_credentials.json?include_email=true HTTP/1.1
Authorization:
OAuth oauth_consumer_key="xxxxxxxxxxxxxxxxx",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1457087650",oauth_nonce="727595198",oauth_version="1.0",oauth_token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",oauth_signature="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Host:
api.twitter.com
X-Target-URI:
https://api.twitter.com
Connection:
Keep-Alive

RESPONSE

HTTP/1.1 200 OK
x-frame-options:
SAMEORIGIN
x-rate-limit-remaining:
14
last-modified:
Fri, 04 Mar 2016 10:34:10 GMT
status:
200 OK
Content-Length:
2431
x-response-time:
40
Connection:
keep-alive
x-transaction:
41d9616d3a14956b
Server:
tsa_b
pragma:
no-cache
cache-control:
no-cache, no-store, must-revalidate, pre-check=0, post-check=0
x-connection-hash:
7e32a2aa426648a6a2528a1ec87fff14
x-xss-protection:
1; mode=block
x-content-type-options:
nosniff
x-rate-limit-limit:
15
expires:
Tue, 31 Mar 1981 05:00:00 GMT
Date:
Fri, 04 Mar 2016 10:34:10 GMT
set-cookie:
lang=en; Path=/
set-cookie:
guest_id=v1%3A145708765046067265; Domain=.twitter.com; Path=/; Expires=Sun, 04-Mar-2018 10:34:10 UTC
x-rate-limit-reset:
1457088550
content-disposition:
attachment; filename=json.json
x-twitter-response-tags:
BouncerExempt
x-twitter-response-tags:
BouncerCompliant
strict-transport-security:
max-age=631138519
x-access-level:
read-write-directmessages
Content-Type:
application/json;charset=utf-8

{
  "id": "xxxxxxxxxxx",
  "id_str": "xxxxxxxxxxxx",
  "name": "Propio",
  "screen_name": "Propio_Home",
  "location": "Israel",
  "description": "Real estate marketing in Israel",
  "url": "https://t.co/tnSaKC5JJ2",
  "entities":  {
    "url":  {
      "urls":  [
         {
          "url": "https://t.co/tnSaKC5JJ2",
          "expanded_url": "http://www.propio.co.il",
          "display_url": "propio.co.il",
          "indices":  [
            0,
            23
          ]
        }
      ]
    },
    "description":  {
      "urls":  []
    }
  },
  "protected": false,
  "followers_count": 4,
  "friends_count": 0,
  "listed_count": 0,
  "created_at": "Mon Nov 10 10:51:00 +0000 2014",
  "favourites_count": 0,
  "utc_offset": null,
  "time_zone": null,
  "geo_enabled": false,
  "verified": false,
  "statuses_count": 1,
  "lang": "en",
  "status":  {
    "created_at": "Thu Feb 18 12:56:24 +0000 2016",
    "id": 700302846114340900,
    "id_str": "700302846114340864",
    "text": "4 Bedrooms penthouse old north of Tel Aviv -https://t.co/LbThbAGegL",
    "truncated": false,
    "source": "<a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>",
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "in_reply_to_screen_name": null,
    "geo": null,
    "coordinates": null,
    "place": null,
    "contributors": null,
    "is_quote_status": false,
    "retweet_count": 0,
    "favorite_count": 0,
    "entities":  {
      "hashtags":  [],
      "symbols":  [],
      "user_mentions":  [],
      "urls":  [
         {
          "url": "https://t.co/LbThbAGegL",
          "expanded_url": "https://goo.gl/C4mXQz",
          "display_url": "goo.gl/C4mXQz",
          "indices":  [
            44,
            67
          ]
        }
      ]
    },
    "favorited": false,
    "retweeted": false,
    "possibly_sensitive": false,
    "lang": "et"
  },
  "contributors_enabled": false,
  "is_translator": false,
  "is_translation_enabled": false,
  "profile_background_color": "000000",
  "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
  "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
  "profile_background_tile": false,
  "profile_image_url": "http://pbs.twimg.com/profile_images/531851017600507904/O910Sga0_normal.jpeg",
  "profile_image_url_https": "https://pbs.twimg.com/profile_images/531851017600507904/O910Sga0_normal.jpeg",
  "profile_banner_url": "https://pbs.twimg.com/profile_banners/2895487842/1415617110",
  "profile_link_color": "19CF86",
  "profile_sidebar_border_color": "000000",
  "profile_sidebar_fill_color": "000000",
  "profile_text_color": "000000",
  "profile_use_background_image": false,
  "has_extended_profile": false,
  "default_profile": false,
  "default_profile_image": false,
  "following": false,
  "follow_request_sent": false,
  "notifications": false
}

#4

Have you tried to do this from code, rather than using the console tool? I can request my own user’s verify_credentials endpoint with ?include_email=true at the command line using twurl, and it comes back successfully. I actually cannot understand how this can work from the console, since there’s no way for you to accept the “can this app access your email address” prompt - you’re acting as the console app, not as your app with the whitelisted access. With twurl, when I run twurl authorize I’m prompted for all the relevant permissions requested by my app consumer key.

What language or code library are you using? can you provide any more context?


#5

we are using “PHP” as a language and “Abraham Williams (abraham@abrah.am)” as a code library.
Host url is : https://api.twitter.com/1.1/

this is code line:

$twitteroauth->get(‘account/verify_credentials’, array(‘include_email’ => true));

when we click on twitter button on my site we go to following page:

here we have message that, this application will be able to: “See your email address.”;

Further, When we click on sign in button we redirected to our website page where we print and check output. But unfortunately, there we cannot found any email address field.


#6

Use array('include_email' => 'true') (string). Another developer recently discovered that using true (boolean) doesn’t work consistently.


#7

Hi, andypiper
I’ve added the permission to request email address but on a Twitter Auth Page, the email is in the “Will not be able” section.
Thanks for any suggestions.


#8

You might want to try regenerating your app keys.


#9

Thanks but i’ve done that


#10

OK - you’ve also added a privacy policy and TOS URL in the app settings on apps.twitter.com, and checked that the email permission is enabled?

If you still have an issue, you can open a ticket via support.twitter.com/forms/platform and send your app ID (the number in the URL when you’re on apps.twitter.com) so the team can check your permissions are set.


#11

For anyone who might be strugglin with this, here’s what I did. I went through most of the things documentation and Andy spoke of and still no go. Make sure all these are checked off.

I finally tried regenerating a new consumer key and secret in combination with passing ‘include_email’ => ‘true’ on GET account/verify_credentials. Not sure which did the trick, but it works!!! Oh the wasted hours getting this to work lol! I guess thats development for you :slight_smile:


#12

I cant see “see your email address” while authenticating.

I have refresh tokens. TRIED
include_email’ => ‘true’ on GET account/verify_credentials. TRIED
added a privacy policy and TOS URL in the app settings TRIED
email permission is enabled TRIED
What should i do . ? Something missing from me ?


#13

I am experiencing the same problem.

In my callback sevlet

           ConfigurationBuilder builder = new ConfigurationBuilder();
	       builder.setOAuthConsumerKey(Setup.CONSUMER_KEY);
	       builder.setOAuthConsumerSecret(Setup.CONSUMER_SECRET);
	       builder.setOAuthAccessToken(accessToken.getToken());
	       builder.setOAuthAccessTokenSecret(accessToken.getTokenSecret());
	       builder.setIncludeEmailEnabled(true); 	       
	       User u = twitter.verifyCredentials();
	       System.out.println(u.toString());

Results printed in the console

    UserJSONImpl{id=218997731, name='Teddy Madile', email='null', screenName='Mad_Ted', location='Gaborone, Botswana', description='Thats for you to find out', isContributorsEnabled=false, profileImageUrl='http://pbs.twimg.com/profile_images/808248163362603008/l5klf1wW_normal.jpg', profileImageUrlHttps='https://pbs.twimg.com/profile_images/808248163362603008/l5klf1wW_normal.jpg', isDefaultProfileImage=false, url='https://t.co/yggDunCZg7', isProtected=false, followersCount=40, status=StatusJSONImpl{createdAt=Mon Dec 12 12:00:17 CAT 2016, id=808250109293195264, text='https://t.co/MTXjLLLEcJ', source='<a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>', isTruncated=false, inReplyToStatusId=-1, inReplyToUserId=-1, isFavorited=false, isRetweeted=false, favoriteCount=0, inReplyToScreenName='null', geoLocation=null, place=PlaceJSONImpl{name='Botswana', streetAddress='null', countryCode='BW', id='8a927a7056322151', country='Botswana', placeType='country', url='https://api.twitter.com/1.1/geo/id/8a927a7056322151.json', fullName='Botswana', boundingBoxType='Polygon', boundingBoxCoordinates=[[Ltwitter4j.GeoLocation;@457580f9], geometryType='null', geometryCoordinates=null, containedWithIn=[]}, retweetCount=0, isPossiblySensitive=false, lang='und', contributorsIDs=[], retweetedStatus=null, userMentionEntities=[], urlEntities=[], hashtagEntities=[], mediaEntities=[MediaEntityJSONImpl{id=808250035175616512, url='https://t.co/MTXjLLLEcJ', mediaURL='http://pbs.twimg.com/media/Czd7H-xW8AA1r4V.jpg', mediaURLHttps='https://pbs.twimg.com/media/Czd7H-xW8AA1r4V.jpg', expandedURL='https://twitter.com/Mad_Ted/status/808250109293195264/photo/1', displayURL='pic.twitter.com/MTXjLLLEcJ', sizes={0=Size{width=150, height=150, resize=101}, 1=Size{width=680, height=636, resize=100}, 2=Size{width=900, height=842, resize=100}, 3=Size{width=900, height=842, resize=100}}, type='photo', videoAspectRatioWidth=0, videoAspectRatioHeight=0, videoDurationMillis=0, videoVariants=0, extAltText='null'}], symbolEntities=[], currentUserRetweetId=-1, user=null, withHeldInCountries=null, quotedStatusId=-1, quotedStatus=null}, profileBackgroundColor='C0DEED', profileTextColor='333333', profileLinkColor='0084B4', profileSidebarFillColor='DDEEF6', profileSidebarBorderColor='C0DEED', profileUseBackgroundImage=true, isDefaultProfile=false, showAllInlineMedia=false, friendsCount=27, createdAt=Tue Nov 23 19:24:23 CAT 2010, favouritesCount=1, utcOffset=-1, timeZone='null', profileBackgroundImageUrl='http://pbs.twimg.com/profile_background_images/615346876/721074xmtze80ilmc9se.jpeg', profileBackgroundImageUrlHttps='https://pbs.twimg.com/profile_background_images/615346876/721074xmtze80ilmc9se.jpeg', profileBackgroundTiled=true, lang='en', statusesCount=51, isGeoEnabled=true, isVerified=false, translator=false, listedCount=0, isFollowRequestSent=false, withheldInCountries=null}

I am using the Twitter4j Core 4.0.6 library.

I have searched various forums, and people reported that it has worked for them.

The email field still returns null.


#14

Hello, I have a question where can get this URLs “privacy policy and TOS URL” ???


#15

You need to provide those URLs for your own app so that a user can learn your privacy policy and terms of service and the reason you are requesting their email address.


#16

What must I do to show window with confirmation that user allow user him
email address?


#17

You’ll need to implement a sign-in with Twitter flow in your application. Many of the available client libraries for Twitter provide examples that show how to do this.


#18

I have Twitter sing-in.
What am I do wrong?
See attached screen.


#19

That looks correct. Once you’ve gone through the flow, you should be able to use the tokens on the verify_credentials call to request the email address (if the address is verified).


#20

What version of OAuth must I use?