Not returning User's Email address in External Callback


#1

Hi,

I’m implementing external login in Asp.Net Web API application using Asp.Net core 2.0 with C#. While login using twitter option, the application is redirecting to twitter login page and after successful login, it is calling application’s call Back method. In that method, we’re trying to get logged in user’s email/username but unfortunately, it doesn’t return. Other provider like Google, LinkedIn are returning. The piece of code which I’m using to get an email address is given below:

        var info = await _signInManager.GetExternalLoginInfoAsync();
            var email = info.Principal.FindFirstValue(ClaimTypes.Email);


#2

Hi @systems_app,

Last month we announced a new requirement that any developer using Sign in with Twitter must explicitly declare their callback URLs in a whitelist on apps.twitter.com by June 12th. This is most likely the cause of the error.

You can fix this error easily, by whitelisting all of your callback URLs in your app settings on apps.twitter.com. Here is a link to the documentation which will guide you through the quick process of enabling this.


#4

In order to retrieve a user’s email address, you need to do two things:

  • ensure that your application’s OAuth permissions are set to request email address
  • make a secondary call to account/verify_credentials with the appropriate parameter to request email address.

Read the documentation.