SLRequest and email



Hi guys,

I’m developing an iOS app that uses a Twitter SignIn. Since I’m on iOS, I implemented both the ACAccount framework (to check local Twitter account on the iPhone) and TwitterKit pod from Twitter.

I need the user email in order to create an account. I asked for a whitelist of my app on the twitter dashboard (granted so far). If I use the REST API, I manage to get the email through the show.json endpoint.

But when I get a local account with the ACAccountStore, I can’t get an email. I tried to call the REST API with this, but the email is never returned :slight_smile:

let twitterAccount = accountsArray[0] as! ACAccount
let url = NSURL(string: "")
let request = SLRequest(forServiceType: SLServiceTypeTwitter, requestMethod: SLRequestMethod.GET, URL: url!, parameters: ["screen_name" : twitterAccount.username])
                                                                request.account = twitterAccount
                                                                request.performRequestWithHandler({ (data: NSData!, response: NSHTTPURLResponse!, error: NSError!) in
                                                                    SocialNetworkManager.handleTwitterResponse(data, error: error)

My guest so far is that there is absolutely no link between my iOS app and my twitter app since when I use the ACAccount framework, I don’t use the consumer key and secret.

My question in the end is pretty simple : is there a way to retrieve the email using an SLRequest, or do I have to use TwitterKit to achieve this?



You can access it but you need to make sure that you have refreshed your keys because all the previously generated keys have not the email authorization granted.

Try this and check if it works.

Also the email will be provided in the the endpoint with the include_email set to true.


Hi and thanks for your answer,

I refreshed my credentials, but how could it work since I never entered my bundleId or anything on the twitter app. There is absolutely no link between my iOS app and the twitter app when I use the SocialNetwork framework, so how can it work?



I am not an iOS developer but if SocialNetwork is actually using your application you must have entered the bundle credentials. If you did not its own app credentials and therefore you will not have access to the email.

Another way SocialNetwork would be able to solve this problem is that Twitter granted Apple with username/password authentication and that you authenticated on your phone.


I’m not aware of any way to do this using SLRequest at the moment. I would definitely suggest using Twitter Kit from Fabric as this has built-in capabilities once the app is whitelisted.

As @TweetinviApi mentioned, even with a regular REST request, you can only get the email address from the verify_credentials endpoint, not from users/show.


That is what I ended up doing :wink:
Thanks for the hint though.