Fabric Android: RequestEmail not get the user email

fabric
login
email

#1

Hi @bonnell

I saw your answer in this post: Android requestEmail Fabric SDK

I did the changes as you said in this comment:


Thanks, you should use your Twitter Consumer Key that you made via apps.twitter.com. In your AndroidManifest, Build.gradle or fabric.properties file, you should have your API key listed.

But, When I put the Twitter Consumer Key in io.fabric.ApiKey I get the following error:

Error:Execution failed for task ':app:fabricGenerateResourcesDebug'.
> Crashlytics Developer Tools error.

Could you help me with this?


#2

Hey @gabyquilarque,

Thanks for reaching out on this! That code: io.fabric.ApiKey would only be for your app’s Fabric API key. For using the Twitter Consumer Key, check out this link: https://fabric.io/kits/android/twitterkit/install specifically “Initialize Your Kit” and you’ll see where to place that key.

Let me know how that goes!


#3

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.