iOS and Twitter OAuth Login

I have recently been working on a iOS (iPhone) application for a client. This app needed to have the ability to post things to Twitter and Facebook.

Facebook provides a really nice SDK which (with a few hacks) provides an inline login dialog which handles all the oAuth details for you. It looks good and works well.

Twitter unfortunately does not do the same and while there are hundreds of Twitter-iOS libraries out there, they are all overly complicated and provide a UI which is not consistent with how the Facebook SDK does things, which if i want my app to appear good and consistent then they must look and behave the same.

The other main reason was because the libraries were overly complicated, they used the “Out of band” oAuth authentication which means a user has to copy a pin from a web page into the application, which is hardly a nice thing to do. Yet Facebook doesn’t have to do this. After a bit of investigation i found out twitter didn’t have to either.

To solve all of this i have created a simple demo application and library, utilizing the Facebook-iOS-SDK and PlainOAuth (by Jaanus Kase) projects as a basis and building what i wanted on top.

A lot of the code should be self explanatory. And below is a screen shot of what the end result is. You can find the project on git hub here: https://github.com/lloydsparkes/unoffical-twitter-sdk

6 thoughts on “iOS and Twitter OAuth Login

  1. Thanks for creating it!

    If I would like to send a twit once the app granted me permissions, what should I do ?

    Does your library provides only a login method ? or does it also provides an API for the twitter API ?

    Thank you,

    • Using the various keys and tokens collected from twitter you should be able to use the to send a tweet.
      I dont provide a API for this (although alot of the code could be easily reused to do this) i just provide a login method. You should be able to find some iOS twitter libraries using google.

  2. Dude! It’s just what I was looking for.
    Thanks for your work.

    By the way, Im having an issue:

    Im introducing OAUTH_CONSUMER_KEY and OAUTH_CONSUMER_SECRET but for some reason Im getting this message at Twitter Modal window:

    Woah there!

    This page is no longer valid. It looks like someone already used the
    token information you provided. Please return to the site that sent
    you to this page and try again … it was probably an honest mistake.

    Help!

    Thanks in advance

    • Andrés, I know this is really late on this but you need to update line ~490 on TwitterDialog.m and change the url to:


      http://api.twitter.com/oauth/authenticate

      Notice authorize has been changed to authenticate.

Leave a Reply