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

This entry was posted in Apple, C / C++, Twitter. Bookmark the permalink.

6 Responses to iOS and Twitter OAuth Login

  1. Ricardo Quesada says:

    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,

    • Lloyd Sparkes says:

      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. Andrés says:

    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

  3. Mills Joshi says:

    Thanks a lot..I took 2 days to find this.
    Really appreciate your efforts. :)

  4. Mills Joshi says:

    Can you please tell me how can i get the user account details from twitter after logging in?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>