Ahmed Abd Elaziz
Ahmed Abd Elaziz

Reputation: 59

TwitterKit issue with signin

I'm using Twitterkit for the first time with firebase and I think I made everything as it should be but I'm receiving this error message every time I trying to test it.

twitterauth://authorize?consumer_key=xxxxxxxxx&consumer_secret=xxxxxxxxxxxxx&oauth_callback=twitterkit-xxxxxxxxxxx&identifier=xxxxxxxxxxxxxxx/xxxxxxxxxxx: Error Domain=NSOSStatusErrorDomain Code=-10814 "(null)" UserInfo={_LSLine=247, _LSFunction=-[_LSDOpenClient openURL:options:completionHandler:]}
2020-02-17 20:04:47.145688+0200 COOKBOOK[8823:136924] [TwitterKit] Error obtaining user auth token.
Request failed: forbidden (403)

In my SignInViewController:

var twitterSession: TWTRSession?

@objc func signinTwitter() {
        TWTRTwitter.sharedInstance().logIn(with: self) { (session, error) in
            if session != nil {
                print(session?.userName)
            }
            guard let session = session else {return}
            self.twitterSession = session
            self.signIntoFirebaseWithTwitter()
        }
    }

    func signIntoFirebaseWithTwitter() {
        guard let twitterSession = twitterSession else {return}
        let credential = TwitterAuthProvider.credential(withToken: twitterSession.authToken, secret: twitterSession.authTokenSecret)
        Auth.auth().signIn(with: credential) { (user, error) in
            if let error = error {
                print(error)
            }
        }
    }

In AppDelegate:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        TWTRTwitter.sharedInstance().start(withConsumerKey: Services.appKey, consumerSecret: Services.appSecretKey)
        return true
    }

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        return TWTRTwitter.sharedInstance().application(app, open: url, options: options)
    }

Info.plist

URL Schemes

LSApplicationQueriesSchemes

I'm using:

  1. Xcode 11.3.1
  2. iOS 13.3.1

Upvotes: 0

Views: 1005

Answers (1)

petra15
petra15

Reputation: 1

Add callback URLs to TwitterApp:

twittersdk://
twitterkit-apikey://

Upvotes: 0

Related Questions