无法从Twitter登录获取电子邮件

时间:2018-02-14 07:28:46

标签: ios swift twitter firebase-authentication twitter-oauth

我一直试图从Twitter登录电子邮件好几天。根据Docs和堆栈的所有内容都溢出了。仍然得到相同的回复,This user does not have an email address.。试图用2种方法收到电子邮件。

方法1 :(这里json不包含电子邮件)

let request = TWTRAPIClient.withCurrentUser().urlRequest(withMethod: "GET", url: "https://api.twitter.com/1.1/account/verify_credentials.json", parameters: ["include_email": "true", "skip_status": "true"], error: nil)

    TWTRAPIClient.withCurrentUser().sendTwitterRequest(request, completion: { (response, data, error) in

        if let error = error {
            print(error.localizedDescription)
            return
        }
        guard let data = data else { return }
        do {
            if let json = try JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? [String: AnyObject] {
                print(json) // this json did not contain email
            }
        } catch let jsonError {
            print(jsonError)
        }
    })

方法2 :(始终提出错误说This user does not have an email address.

TWTRAPIClient.withCurrentUser().requestEmail(forCurrentUser: { (email, error) in
    if let error = error {
        print(error.localizedDescription) // gave output "This user does not have an email address."
        return
    }
    if let email = email {
        print(email)
    }
})

多次生成新密钥并在App中更新它们。仍然得到同样的错误。 Android应用程序使用iOS中使用的相同密钥即可获得电子邮件。提前谢谢。

1 个答案:

答案 0 :(得分:1)

要获取用户电子邮件地址,您的应用应列入白名单。Use this form。您可以发送邮件到sdk-feedback@twitter.com,其中包含有关您的应用程序的一些详细信息,如消费者密钥,应用程序的App Store链接,隐私政策链接,元数据,如何登录我们的应用程序的说明等等。他们将在2-3个工作日内回复。

将您的应用列入白名单后,您可以使用Twitter Framework或API来收发电子邮件。