Login with twitter always return error

℡╲_俬逩灬. 提交于 2019-12-11 15:25:36

问题


I am try to add login with twitter but some how I am not able to get response. Everytime I got the error message (error obtaining user auth token). I know there are lot's SO post which has this issue but I am not able to login. I also try advance setting but I got session nil. I also regenerate the consumer key and Secret but no luck. using swift 3.0

Here is my code

TWTRTwitter.sharedInstance().logIn(with: self) { (session, error) in
     if (session != nil) {
     print("signed in as \(session?.userName ?? "")");
            } else {
                print("error: \(error?.localizedDescription ?? "")");
            }
     }

info.plist

Appdelegate

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        _ = DBSingleton.sharedInstance
        TWTRTwitter.sharedInstance().start(withConsumerKey:TwitterKey.consumerKey, consumerSecret:TwitterKey.consumerSecret)
}

Update: if we have application then it works fine but if not then it return errors.


回答1:


After lot of R&D I got the success. Twitter has made call back url compulsory. I found from this link

You need to add twitterkit-xxxxxxxxxxxxxxxx (twitterkit-consumer key) in call back url at twitter dashboard setting.

I used this method for opening safari (make sure you add safari framework)

TWTRTwitter.sharedInstance().logIn(with: self) { (session, error) in
            if (session != nil) {
                print("signed in as \(session?.userName ?? "")");
            } else {
                print("error: \(error?.localizedDescription ?? "")");
            }
        }


来源:https://stackoverflow.com/questions/51401016/login-with-twitter-always-return-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!