Home > other >  How to authenticate using the installed Twitter app
How to authenticate using the installed Twitter app

Time:09-27

If the user is logged-in with the native Twitter app installed, I want my app to open the Twitter app to request authorization.

I already implemented the flow to get the oauth_token in order to start the login process through Twitter's api. Only, the current API Documentation do not mention anything about how to use the native iOS app in the process. It only sends back a url for the user to log in.

let url = URL(string: "https://api.twitter.com/oauth/authorize?oauth_token=\(result.oauthToken)")!
            
DispatchQueue.main.async {
   UIApplication.shared.open(url)
}

On getting the requested oauth_token, I get this link. Opening the link will display a Webview to login. Not the native Twitter iOS app.

I tried to use a deeplink to manually launch the Twitter app, but I couldn't found any resources on how to setup the link properly.

So far I have tried things like:

twitterauth://authorize?consumer_key=[KEY]&consumer_secret=[SECRET]&oauth_callback=swifter-[KEY]

or

twitterauth://authorize?oauth_token=\(result.oauthToken)

without any success...

As mentioned in another post, Clubhouse has implemented exactly this flow. So it is possible. The question is how ?

  • Related