# Getting empty email address from twitter social login

**URL:** <https://community.auth0.com/t/getting-empty-email-address-from-twitter-social-login/143930>\
**Category:** Get Help\
**Tags:** other-built-in-social-connections, connections\
**Created:** [September 3, 2024, 9:07am UTC](https://community.auth0.com/t/getting-empty-email-address-from-twitter-social-login/143930 "2024-09-03T09:07:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![developers9](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/developers9/32/60297_2.png) [@developers9](https://community.auth0.com/u/developers9)\
**Post date:** [September 3, 2024, 9:07am UTC](https://community.auth0.com/t/getting-empty-email-address-from-twitter-social-login/143930/1 "2024-09-03T09:07:08Z")

</div>

Hi, I am trying to implement Twitter social login. which is working but Auth0 always showing (empty) email address when I check in User management. I have added Action (previously in rule) and add in in the Flow. Also I already setup my twitter developer account and allow to request for email . After all that, I am still getting email address as empty from auth0.

Can anyone tell me where should i look? in this empty email address 's case

Thank you

 ![image](https://global.discourse-cdn.com/auth0/original/3X/a/5/a5bf3e37bd6a721750bef5ff827b81fced75999d.png)

 ![image](https://global.discourse-cdn.com/auth0/original/3X/b/6/b655b2f0f63ecfa216a6833058e836b68e1f8e3f.png)

This is my script in my action

```auto
function getTwitterEmail(user, context, callback) {
  // additional request below is specific to Twitter
  if (context.connectionStrategy !== 'twitter') {
    return callback(null, user, context);
  }

  const _ = require('lodash');
  const request = require('request');
  const oauth = require('oauth-sign');
  const uuid = require('uuid');

  const url = 'https://api.twitter.com/1.1/account/verify_credentials.json';
  const consumerKey = configuration.TWITTER_CONSUMER_KEY;
  const consumerSecretKey = configuration.TWITTER_CONSUMER_SECRET_KEY;

  const twitterIdentity = _.find(user.identities, { connection: 'twitter' });
  const oauthToken = twitterIdentity.access_token;
  const oauthTokenSecret = twitterIdentity.access_token_secret;

  const timestamp = Date.now() / 1000;
  const nonce = uuid.v4().replace(/-/g, '');

  const params = {
    include_email: true,
    oauth_consumer_key: consumerKey,
    oauth_nonce: nonce,
    oauth_signature_method: 'HMAC-SHA1',
    oauth_timestamp: timestamp,
    oauth_token: oauthToken,
    oauth_version: '1.0'
  };

  params.oauth_signature = oauth.hmacsign(
    'GET',
    url,
    params,
    consumerSecretKey,
    oauthTokenSecret
  );

  const auth = Object.keys(params)
    .sort()
    .map(function (k) {
      return k + '="' + oauth.rfc3986(params[k]) + '"';
    })
    .join(', ');

  request.get(
    url + '?include_email=true',
    {
      headers: {
        Authorization: 'OAuth ' + auth
      },
      json: true
    },
    (err, resp, body) => {
      if (resp.statusCode !== 200) {
        return callback(
          new Error('Error retrieving email from twitter: ' + body || err)
        );
      }
      user.email = body.email;
      return callback(err, user, context);
    }
  );
}

```

and this is the flow

 ![image](https://global.discourse-cdn.com/auth0/original/3X/8/b/8b31ceed0511c6d4df1325c0c027eb762e303dcb.png)

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [February 24, 2025, 2:06am UTC](https://community.auth0.com/t/getting-empty-email-address-from-twitter-social-login/143930/3 "2025-02-24T02:06:23Z")

</div>

Hi There!

You can find the details to fix the above issue here → [X (formerly Twitter) Social Connection Cannot Fetch the Email Attribute when Migrating from Rules to Actions](https://community.auth0.com/t/x-formerly-twitter-social-connection-cannot-fetch-the-email-attribute-when-migrating-from-rules-to-actions/146257)

Thanks  
Dawid

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 10, 2025, 2:07am UTC](https://community.auth0.com/t/getting-empty-email-address-from-twitter-social-login/143930/4 "2025-03-10T02:07:21Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
