Dec 4th Why use Twitter OAuth

Back in April, Twitter quietly released the Sign in with Twitter feature allowing account owners to log in to 3rd party websites. Even though Facebook has offered the same service (Facebook Connect) for well over a year, Twitter’s solution remains the easiest to implement.

If you are looking for a fast way to implement a membership system without the hassle of programming a registration and login module, Sign in with Twitter may be your best bet. Not only will you be saving development time, but in the long run you may actually get a lot more members than with a normal registration form.

Think about it… How many times have you visited a site and landed on a registration page to find an endless form and an e-mail activation at the end of all of it.  Speaking for myself, this is a major turn off. I find myself registering to more websites that have the social sign in feature than those that don’t. After all it’s a matter of a few clicks and I am registered on the site.

As of today, Twitter has 23 million unique visitors per month. Most of those visitors have a Twitter account, hence would automatically have an account on your website as well.

The sign in process cannot be any easier for the end-user, it’s really a matter of:

  1. Clicking the ‘Sign in with Twitter’ button
  2. Allowing the application to gain access to your information
  3. That’s it! You are now logged in!

Not only will your visitors be able to register with a few clicks, but they will not be obliged to remember an additional username.

For obvious reasons, if time isn’t an issue you should still program the typical registration and login form. After all, you still want the people that do not have Twitter to register.

Another interesting option would be to allow existing users to associate their Twitter account. By doing so, the user can either login using his Twitter or with the website’s login.

The idea is to add a twitter_account_id column to your existing users table. When someone tries to login with Twitter OAuth, you attempt to load the account linked to that Twitter account and proceed to the normal login process.

You could also do something a little bit more advanced and add a Many-to-One table with the following columns:

  • user_id unsigned int(10)
  • site ENUM(‘twitter’, ‘facebook’)
  • account_id unsigned int(10)

In essence, this would allow each user to have multiple social website accounts. This could be interesting for the person wanting to link his Twitter as well as his Facebook account to their account.

You can speed up queries by adding a UNIQUE index on all 3 columns and a foreign key from user_id to the primary key of your users table.

-Christian Joudrey

Comments are closed.