Request email user

android
email
java

#1

Hi, all

I am trying to request the email from a user using the twitter login and it always return me the following error

com.twitter.sdk.android.core.TwitterException: Your application may not have access to email addresses or the user may not have an email address. To request access, please visit https://support.twitter.com/forms/platform.

I’ve followed all the steps to develop this email request in the fabric’s page. I’ve requested the access to twitter and they have answered me with a confirmation email and I’ve configured all the necessary items in my twitter app management control panel, but the email request always send me to the failure method and throw that exception.

any idea?

    private void twitterConfig() {
    TwitterAuthConfig authConfig =
            new TwitterAuthConfig("xxxxxxxxxxx",
                    "xxxxxxxxx");

    Fabric.with(this, new Twitter(authConfig));
    twitterLoginButton.setCallback(new Callback<TwitterSession>() {
        @Override
        public void success(Result<TwitterSession> result) {
            TwitterSession session = result.data;
            String msg = "@" + session.getUserName() + " logged in! (#" + session.getUserId() + ")";
            TwitterAuthClient authClient = new TwitterAuthClient();
            authClient.requestEmail(session, new Callback<String>() {
                @Override
                public void success(Result<String> result) {
                    System.out.println();
                }

                @Override
                public void failure(TwitterException exception) {
                    notificationManager.showMessage(getString(R.string.error_cant_get_login));
                }
            });
        }

        @Override
        public void failure(TwitterException exception) {
            notificationManager.showMessage(getString(R.string.error_generic));
        }
    });
}

#2

Hey @DrMunon,

If you’re still encountering this, can you try a clean of your project and let me know if that helps? If not, can you let me know the email address you wrote in with so that I can do a double-check on your keys?

-Mike


#3

Yeah I still encountering this. A clean of my project doesn’t help.

My email is drmalignobo@gmail.com

Thanks


#4

Thanks @DrMunon, can you let me know which app you’re seeing this on? I see multiple under that account.

-Mike


#5

I’ve tried with all of them, the last of all, 9086028. I think that the id app is the one which appears in the url.


#6

Is this problem solved? I am facing the same problem in my app


#7

Hey @singh_hiten,

There are a potential couple of issues for why you’re not getting the email address. The most common is that your Twitter Consumer Key and Secret have not been given permission as this permission needs to be explicitly requested. Have you requested and been granted this permission? If so, double check that you’re using the key that was given the permission.

-Mike


#8

Thank you sir for your response, i did requested for permission and got response from support@twitter.com that my app can request email. I think i am unable to implement it in android, what i’ve tried till now:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    Fabric.with(getContext(), new Twitter(authConfig));
    }
     //...
    loginButton.setCallback(new Callback<TwitterSession>() {
        @Override
        public void success(Result<TwitterSession> result) {

            TwitterSession session = result.data;
            TwitterAuthToken authToken = session.getAuthToken();
            String token = authToken.token;
            String secret = authToken.secret;

            Log.d(TAG, "token: "+token);
            // TODO: Remove toast and use the TwitterSession's userID
            // with your app's user model
            String msg = "@" + session.getUserName() + " logged in! (#" + session.getUserId() + ")";
            Toast.makeText(getContext(), msg, Toast.LENGTH_LONG).show();
            TwitterAuthClient authClient = new TwitterAuthClient();

            authClient.requestEmail(session, new Callback<String>() {
                @Override
                public void success(Result<String> result) {
                    Toast.makeText(getContext(), result.toString(), Toast.LENGTH_LONG).show();
                }

                @Override
                public void failure(TwitterException exception) {
                exception.printStackTrace();
                }
            });
            AccountService ac = Twitter.getApiClient(result.data).getAccountService();
            TwitterApiClient client = Twitter.getApiClient(result.data);

        }

        @Override
        public void failure(TwitterException exception) {
            Log.d("TwitterKit", "Login with Twitter failure", exception);
        }

    });

and in my manifest file

    <meta-data
        android:name="io.fabric.ApiKey"
        android:value="**************************************" />

is there anything i am missing?


#9

The code looks correct - what’s the response you’re getting back from the server? Also, if you’re using an account that had previously already been authenticated with your app, you would need to log into the account’s Twitter settings, revoke access and then re-authenticate the app.

-Mike


#10

The response i am getting is
com.twitter.sdk.android.core.TwitterException: Your application may not have access to email addresses or the user may not have an email address. To request access, please visit https://support.twitter.com/forms/platform.

i revoked access from my twitter account as well, and then re-authenticated in my app.

One more thing i found that the token and secret i am getting from TwitterAuthToken inside success are not same as Access Token and Access Token secret in my https://apps.twitter.com/app/********/keys

Could that be an issue?


#11

Hey @singh_hiten,

If you’re seeing that error, then it means the key you’re using does not have permission to access the email address. If you’re seeing a disconnect in the keys, then it sounds like there is a discrepancy as to which one is being used. I would use the key and secret that you requested be granted the permission.
-Mike


#12

I am facing the same problem in my app.

I did everything I needed to do programming, but the email came “null”, and I learned that my application should be on the whitelist by Twitter. I am ready to give any information to add my application to the whitelist.

I use a fabric and my keys are available at apps.twitter.com too. The keys that I use in the app are from apps.twitter.com.

If I use the keys from the fabric.io in my class, I get an same error:

“Your application may not have access to email addresses or the user may not have an email address.”

I have sent e-mail to the fabric and twitter help desk. Is there anything else I can do?

Thanks in advance.


#13

We are facing the same problem in our app (app id is 13710698).
We’ve already done the following steps:

  • request to add all fabric permissions to it
  • revoke and regenerate old access tokens with old permission sets (many times).
    We have noticed that when we regenerate the token access, the new one has the access level to “Read, write, and direct messages”, but after the login the token access is replaced with one with only “Read and write” access.

Please help us to resolve this issue.

Thanks in advance.


#14

Hi All,

I am also facing same issue,

In my android application I have integrated twitter login. After successful login in twitter, I am not able to get the user email id. I am facing this problem only in android-6 but in android-5 I am able to get the user email id.
One thing I have notices is that twitter login screen is differ in android-5 and android-6. In android-5 I can able to see all the permission refer the attached image, but in android-6 I cannot see those permissions.

Please find attached twitter login screen in android-5 android-6.

Android 5 twitter login flow

Android 6 twitter login flow

Please let me know what will be the issue.

Thanks in advance.


#15