Custom twitter login button and get email address



Hi there.

I have this code block for custom twitter login button:

@IBAction func twitter(_ sender: Any) {
    Twitter.sharedInstance().logIn(withMethods: [.webBased]) { session, error in
        if (session != nil) {
            let client = TWTRAPIClient.withCurrentUser()
            let request = client.urlRequest(withMethod: "GET", url: "", parameters: ["include_email": "true", "skip_status": "true"], error: nil);
            client.sendTwitterRequest(request) { response, data, connectionError in
                let json = JSON(data: data!);
        } else {
            print( error?.localizedDescription );

First question is what is currently login type (withMethods) parameters. Like, webBased.

Example, can I use .appBased or etc?

2 - print(json); looks pretty good, but I still need the email address. How can I get it?

Thank you!


Hey @Eggdrop,

Requesting an email address from a user requires your app to be whitelisted by the Fabric team. Please email into support(at)fabric(dot)io with your Twitter Consumer Key and link to your Privacy Policy!



Hi Mike,

Thank you for your interest.

I created new application at and I requested for permission. They are give permission to me.

But I’m trying with new keys. Result is same. I still can’t see the email fields.

Whats wrong?


I found the problem:

This work:
Twitter.sharedInstance().logIn(withMethods: [.webBased])

This wont work:

Thank you all!