Thanks for your answers @bonnell
I found the solution to my problem!! I was finishing writing this post when I got the error, so I was finishing writing this post when I got the error. I also publish this answer to help other people who may have the same problem.
Problem Statement:
I want request user email address. I did the instructions for this link. The Login with twitter works perfectly. I can get the token and secret, but I can not get the email address.
This is my code:
In my Activity:
private static final String TWITTER_KEY = "xxxxx";
private static final String TWITTER_SECRET = "yyyyyyyyyy";
private TwitterLoginButton loginButtonTwitter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new Crashlytics(), new Twitter(authConfig));
loginButtonTwitter = (TwitterLoginButton)
findViewById(R.id.twitter_login_button);
loginButtonTwitter.setCallback(new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
// Do something with result, which provides a TwitterSession for making API calls
TwitterSession session = Twitter.getSessionManager().getActiveSession();
TwitterAuthToken authToken = session.getAuthToken();
String token = authToken.token;
String secret = authToken.secret;
Log.i(TAG,"TOKEN TWITTER:" + token);
Log.i(TAG,"SECRET TWITTER:" + secret);
TwitterAuthClient authClient = new TwitterAuthClient();
authClient.requestEmail(session, new Callback<String>() {
@Override
public void success(Result<String> result) {
// Do something with the result, which provides the email address
Log.i(TAG," EMAIL EXITO!");
Log.i(TAG,"RESULT:" + result.data);
}
@Override
public void failure(TwitterException exception) {
// Do something on failure
Log.i(TAG,"EMAIL FAILURE");
}
});
}
@Override
public void failure(TwitterException exception) {
// Do something on failure
Log.i(TAG,"ACCES FAILURE");
}
});
In my AndrioidManifest.xml
<meta-data
android:name="io.fabric.ApiKey"
android:value="zzzzzz" />
My Permissions from apps.twitter.com:
My email from support@twitter.com:
My Twitter Settings:(figure 3)
SOLUTION:
I just has to revoke access from My Twitter Setting(see figure 3) and after grant access from my app again and Done!.
Thanks @bonnell for your answers in this post and in other post.