Get Twitter Email Address and First&Last Name


#1

I’m still having problem getting email address from Twitter after whitelisted even I allowed to use email.

Error Domain=TwitterAPIErrorDomain Code=32 “Request failed: unauthorized (401)” UserInfo=0x7fb8204476f0 {NSErrorFailingURLKey=https://api.twitter.com/1.1/account/verify_credentials.json?skip_status=true&include_email=true, NSLocalizedDescription=Request failed: unauthorized (401), NSLocalizedFailureReason=Twitter API error : Could not authenticate you. (code 32)}

Here is my code:

let twitterInstance = Twitter.sharedInstance()
        twitterInstance.startWithConsumerKey(TwitterClientKey, consumerSecret: TwitterClientSecret)
        
        twitterInstance.logInWithCompletion {
            (session, error) -> Void in
            if (session != nil) {
                println("signed in as \(session.userName)");
                
                if (twitterInstance.session() != nil) {
                    if let shareEmailViewController = TWTRShareEmailViewController(completion: {
                        (email: String!, error: NSError!) in
                        if (email != nil) {
                            print("TW EMAIL: \(email)")
                        } else {
                            print("TW ERROR: \(error)")
                        }
                    }) {
                        self.presentViewController(shareEmailViewController, animated: true, completion: nil)
                    }
                } else {
                    print("User not logged in")
                }
                
                
            } else {
                println("error: \(error.localizedDescription)");
            }
        }



#2