用Twitter登录失败“获取用户身份验证令牌时出错”

时间:2019-08-03 16:02:04

标签: ios swift twitter

我想在我的应用程序中使用登录Twitter,我遵循了Twitter仪表板和安装指南中的所有说明,但是当我运行我的应用程序时,它给了我这个错误

在信息中心中有回调网址,我不知道要设置什么 我用这个: 回调网址 http://twitterkit-7K3f5fZ98fNFGu7N8Aslo936c

这是我在AppDelegate中使用的代码

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
TWTRTwitter.sharedInstance().start(withConsumerKey:"7K3f5fZ98fNFGu7N8Aslo936c", consumerSecret:"FYfOSgeGd5VAge6DuxersYIfpSaLGPfUK5cME50Z1KpbTLI2WK")
  return true
 }
application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
 if TWTRTwitter.sharedInstance().application(app, open: url, options: options){
            return true
        }
  return false
        }

//和在LoginViewController中

 // Swift
        let logInButton = TWTRLogInButton(logInCompletion: { session, error in
            if (session != nil) {
                print("signed in as \(session?.userName)");
            } else {
                print("error: \(error?.localizedDescription)");
            }
        })
        logInButton.center = self.view.center
        self.view.addSubview(logInButton)

运行应用程序时出现错误

2019-08-03 17:44:35.503573+0200 Kuwait Calendar[2401:238906] [TwitterKit] Error obtaining user auth token.
error: Optional("Request failed: forbidden (403)")

或此错误

2019-08-03 17:19:11.530475+0200 Kuwait Calendar[2198:174628] CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
    class = inet;
    "m_Limit" = "m_LimitAll";
    ptcl = htps;
    "r_Attributes" = 1;
    sdmn = "https://api.twitter.com";
    srvr = "api.twitter.com";
    sync = syna;
}
2019-08-03 17:19:11.820783+0200 Kuwait Calendar[2198:174430] [TwitterKit] Error obtaining user auth token.
error: Optional("Request failed: unauthorized (401)")

0 个答案:

没有答案