Can't get email from twitter

ios
fabric
email

#1

I’m not able to get email from twitter, I already request for special permission from twitter to access email. Android they got email from twitter with the same account.I’m not sure what I’m doing wrong , can anybody help me to fix it out.(I’m using fabric kit for twitter).
My request as ,

  [[Twitter sharedInstance] logInWithMethods:TWTRLoginMethodWebBased completion:^(TWTRSession * _Nullable session, NSError * _Nullable error) {
                    
                    if (session) {
                        
                        TWTRAPIClient *client = [TWTRAPIClient clientWithCurrentUser];
                        
                        NSURLRequest *request = [client URLRequestWithMethod:@"GET"
                                                                         URL:@"https://api.twitter.com/1.1/account/verify_credentials.json"
                                                                  parameters:@{@"include_email": @"true", @"skip_status": @"true"}
                                                                       error:nil];
                        
                        [client sendTwitterRequest:request completion:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
                             NSLog(@"tMail%@",response);
                            
                        }];
                        
                        
                    }
                }];

And the response as,

{
"contributors_enabled" = 0;
"created_at" = "Thu Jan 19 04:12:34 +0000 2012";
"default_profile" = 1;
"default_profile_image" = 0;
description = "";
entities =     {
    description =         {
        urls =             (
        );
    };
};
"favourites_count" = 0;
"follow_request_sent" = 0;
"followers_count" = 4;
following = 0;
"friends_count" = 1;
"geo_enabled" = 0;
"has_extended_profile" = 0;
id = 468064308;
"id_str" = 468064308;
"is_translation_enabled" = 0;
"is_translator" = 0;
lang = en;
"listed_count" = 0;
location = "";
name = "MASILAMANI.K";
notifications = 0;
"profile_background_color" = C0DEED;
"profile_background_image_url" = "http://abs.twimg.com/images/themes/theme1/bg.png";
"profile_background_image_url_https" = "https://abs.twimg.com/images/themes/theme1/bg.png";
"profile_background_tile" = 0;
"profile_image_url" = "http://pbs.twimg.com/profile_images/681481627898257408/8VqTPA55_normal.jpg";
"profile_image_url_https" = "https://pbs.twimg.com/profile_images/681481627898257408/8VqTPA55_normal.jpg";
"profile_link_color" = 0084B4;
"profile_sidebar_border_color" = C0DEED;
"profile_sidebar_fill_color" = DDEEF6;
"profile_text_color" = 333333;
"profile_use_background_image" = 1;
protected = 0;
"screen_name" = AKMASILAMANI;
"statuses_count" = 0;
"time_zone" = "<null>";
url = "<null>";
"utc_offset" = "<null>";
verified = 0;

}

Thanks,
Iniyarajan.S


Deprecated TWTRShareEmailViewController - how to get email?
#2

Hey @InfognanaDevelopers,

One quick question - has this user previously already registered their Twitter account with your app before you requested email address permissions?

-Mike


#3

Hello @bonnell

I am also facing the same issue my account is registered before the app requested email permission.
If I unregister and register again will it work?


#4

Yes, if you remove permission to your app from your Twitter settings page, then re-authenticate the app as authorized and you have the email address permission, you should get the data you’re looking for :slight_smile:


#5

I got this error message when i revoke permission for the App from Twitter Setting :

Error: Optional(Error Domain=TwitterAPIErrorDomain Code=89 "Request failed: unauthorized (401)" UserInfo={NSLocalizedFailureReason=Twitter API error : Invalid or expired token. (code 89), TWTRNetworkingStatusCode=401, NSErrorFailingURLKey=https://api.twitter.com/1.1/account/verify_credentials.json?skip_status=true&include_email=true, NSLocalizedDescription=Request failed: unauthorized (401)})

To note, it works fine in my Android app

Thank you,