I want to put a plug in on my website for "login with twitter", and my website needs to get user's twitterID and email after user allows my twitter application to access their data. I looked through the twitter dev documents, but it seems always all about OAuth with complicated examples. Is there an easy way to do this? I already put the same kind of plugin for facebook, and it is very simple. Thanks!
-
Hi @Harshit : How you managed to get `email` through twitter API. I also got stuck in same issue. I asked question here http://stackoverflow.com/questions/36284336/not-getting-email-after-login-through-twitter-api-yii2 . If you have the solution, please help me *Bhai* . – Nana Partykar Mar 29 '16 at 13:47
8 Answers
If twitter doesn't provide any API, then how does foursquare retrieve them?
- Foursquare has provision to list out the user's foursquare-friends who have registered with twitter.
- It also provides API which shows friends of users who commonly appear in 'foursquare friend's list' as well as 'twitter followers list' of the user.
In both the above cases comparison can be made only through email.

- 124
- 1
- 8
There is NO way you can get email address of a twitter user. Twitter doesn't provide it : https://dev.twitter.com/docs/faq#6718

- 1,249
- 2
- 14
- 26
From the twitter api FAQ https://dev.twitter.com/docs/faq
How do I obtain a user's email address?
If you'd like a user's email address, you'll need to ask a user for it within the confines of your own application and service. The Twitter API does not provide the user's email address as part of the OAuth token negotiation process nor does it offer other means to obtain it.

- 3,880
- 2
- 26
- 39
https://dev.twitter.com/rest/reference/get/account/verify_credentials Request a User’s Email Address
Requesting a user’s email address requires your application to be whitelisted by Twitter. To request access, please use this form.
Once whitelisted, the “Request email addresses from users” checkbox will be available under your app permissions on apps.twitter.com. Privacy Policy URL and Terms of Service URL fields will also be available under settings which are required for email access. If enabled, users will be informed via the oauth/authorize dialog that your app can access their email address.

- 53
- 5
Go to https://support.twitter.com/forms/platform Select "I need access to special permissions" Enter Application Name and ID. These can be obtained via https://apps.twitter.com/ -- the application ID is the numeric part in the browser's address bar after you click your app. Permissions Request: "Email address" Submit & wait for response After your request is granted, an addition permission setting is added in your twitter app's "Permission" section. Go to "Additional Permissions" and just tick the checkbox for "Request email addresses from users".

- 31
- 4
Twitter doesn't provide the email address, this is why many websites using OAuth does not implement Twitter;because the user's email address is part of the registration process.

- 8,248
- 8
- 53
- 65
there is no way to get email by twitter, twitter does not provide email in api response.

- 1,429
- 1
- 16
- 26
I'm working on C#.Net and I used the Tweetinvi API, its easy to use and has a good documentation.
Well to answer your question, it's possible get the user's email and all the data.
1st: You need to create your Twitter app on "apps.twitter.com" and register it. Then in the app management you'll find a "Permission" tab and at the end of the page there is a checkbox that says if you need the email information. You'll have to provide a link to your Privacy Terms so the user can read and agree to share the information with your app, you can use 'https://google.com' but its recommended to provide a valid link.
And that's all. In the code, you just need to authenticate the user and get the data you need.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tweetinvi;
using Tweetinvi.Models;
namespace APIS
{
public class TwitterConfig
{
IAuthenticationContext authenticationContext;
/// <summary>
/// Le indica a twitter que va a hacer una consulta de crendenciales. Esta consulta va a generar un PIN en caso de que sea correcto
/// y el usuario tiene que digitar el pin.
/// </summary>
public void RequestForCredentials()
{
var appCredentials = new TwitterCredentials("CONSUMER-KEY", "CONSUMER-SECRET"); //GET THE CONSUMER INFORMATION ON THE TWITTER APP MANAGEMENT
authenticationContext = AuthFlow.InitAuthentication(appCredentials);
//This opens a web-browser and asks to the twitter client
//to accept the terms, and twitter gives a code and the user
// have to introduce it on the app (use the AuthByPin(String pin) method )
//Thats the PIN for auth the user and then get the data
Process.Start(authenticationContext.AuthorizationURL);
}
/// <summary>
/// Metodo que solicita un PIN que un usuario de Twitter al aceptar las condiciones se le brindó y este lo introdujo en la app
/// para ser autenticado.
/// </summary>
/// <param name="pin">PIN del usuario</param>
/// <returns>IAuthenticatedUser devuelve el usuario autenticado y con todos los datos.</returns>
public IAuthenticatedUser AuthByPin(String pin)
{
try
{
// Con este código PIN ahora es posible recuperar las credenciales de Twitter
var userCredentials = AuthFlow.CreateCredentialsFromVerifierCode(pin, authenticationContext);
// Use las credenciales del usuario en su aplicación
Auth.SetCredentials(userCredentials);
var user = User.GetAuthenticatedUser();
return user;
}
catch (Exception e)
{
Console.WriteLine(e);
throw new ApplicationException("Problema al autenticar.", e);
}
}
}
}
</code>
If you have some question ask me

- 1,492
- 1
- 21
- 31

- 3
- 2
-
https://github.com/linvi/tweetinvi Here you can find the Tweentinvi doccumentation! – Denner Portuguez Apr 06 '18 at 23:17