Deprecated TWTRShareEmailViewController - how to get email?

ios
login
mobile

#1

Ever since you folks deprecated TWTRShareEmailViewController your new means of getting email via API is like poo. Ref: https://docs.fabric.io/ios/twitter/request-user-email-address.html
Your documentation sucks. ref:
URL:"https:// missing @ infront of the String.
and when corrected returns:
“API error : Your credentials do not allow access to this resource. (code 220)}”

Just to login I need to make 3 calls.

  1. To login session (logInWithCompletion)
  2. loadUserWithID to get profile image and
  3. Send request to verify_credentials.json to get email

and it fails on #3 with: “https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true&skip_status=true, NSLocalizedDescription=Request failed: forbidden (403), NSLocalizedFailureReason=Twitter API error : Your credentials do not allow access to this resource. (code 220)}”

So what did I miss?


#2

i’m in the same boat. I made corrections to the example and am also receiving a 403.

    TWTRAPIClient *client = [[TWTRAPIClient alloc] init];
    
    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) {
        
        if (connectionError) {
            NSLog(@"error: %@",connectionError.localizedDescription);
        }
        

    }];

#3

Hey there, thanks for the feedback! I’m going to share this with the team to make sure other developers have a smoother experience. In the meantime, I’ve gone ahead and updated our documentation to fix the URL string - really appreciate you letting us know about the mistake! The fix should be visible soon.

It sounds like the Twitter key you’re using doesn’t have privileges to request email addresses. If you send me your Twitter API key to support@fabric.io, I can update your keys and then you should be all set!


#4

@pir800 Your code is requesting the email with an unauthenticated API Client. I apologize for our docs being incorrect for the Objective-C code path. You will want to initialize the client with the code TWTRAPIClient *client = [TWTRAPIClient clientWithCurrentUser] which returns an API client that will send authenticated requests on behalf of the logged in user. We will update the docs to fix this issue.


#5

Thanks Alex. I just emailed my API key.


#6

Chase,

Thanks that took care of the 403 and I’m getting data, but still no email address being returned. I emailed Alex, so hopefully it’s just a permissions issue on your end.


#7

Just sent you an email back! It looks like your keys have the right permissions, so I’d like to dig into your code.


#8

Twitter folks, any updated on my initial post?


#9

@turbz Thanks for following up on this. We’ve updated the documentation with a few changes and thanks for pointing out what we missed.

If you’re still hitting the 403, have you requested that your API key be given access to use this permission? Also, are you using a key created from Fabric or apps.twitter.com?


#10

I’m using the same code from the (hopefully) updated docs. And while I don’t get a 403 message I also don’t get an email. (Even though I’m specifically requesting the email:)

TWTRAPIClient *client = [[TWTRAPIClient alloc] init];
    
    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];

I receive everything but the email and it even says when the user is logging into twitter:

Will not be able to: Access your direct messages
See your email address

Worked just fine (as of yesterday) with the old ShareEmailViewController. But now I updated to the new system and it’s not working.

What gives?


#11

Hey @DHIEnterprises,

Are we also chatting over email? Which method would you prefer - email or here?

-Mike


#12

As Twitter Support team granted the permission to access user’s email address, after that i regenerated the Access token and Token secret keys. Then I implemented the methods as described at https://docs.fabric.io/ios/twitter/request-user-email-address.html# for iOS . I successfully retrieved user details but still i am unable to get their email . Following is the method I am using in my code:

[[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) {
            
       }];
        
        
    }

As the same application is being developed in Android , and I implemented the methods described at https://docs.fabric.io/android/twitter/request-user-email-address.html# . Here I got the user’s email address. So, please let me know if i am missing anything at iOS end.


#13

@Seasia_CC thanks for reaching out on this - can you share your iOS apps bundle id?


#16

@InfognanaDevelopers your posts have been removed duplicates of this thread: Can't get email from twitter