12/06/2013 by Nitesh

How to Authenticate a Twitter User for Twitter using OAuth API V1.1

Friends,

Yesterday, 11th June 2013, Twitter officially closed its V1.0 API and have migrated to v1.1 API now. This means that we need to authenticate users before being able to display tweets from a user’s profile, even it is a public profile. Yes, you read it correct even if the user’s profile is a public profile. This means that to get tweets from any Twitter user’s timeline, we will need to make an authenticated request via oAuth. In case you want to know what oAuth is all about, read it here.

This post will explain you how to authenticate your website / application to display tweets from your timeline. In case you are just interested in displaying tweets from your timeline on your website and nothing much, you do not need to dig into this post, rather you can do it using Twitter Widgets as explained here and if you are not happy with the way it looks on your website and you want to customize it, read this article on customizing the embedded widget.

If you are more technical, read on! To be able to connect twitter using oAuth, we need to do 2 most important steps –

  1. Create a Twitter App
  2. Connect with the App using a library in language of your choice.

The very first thing that you will need to do is to create an app on Twitter. So, let us start building an app on Twitter. To create an app on Twitter, follow the below steps –

  • Go to https://dev.twitter.com/apps  and log in with your Twitter credentials.1
  • Since this is the first time you are logging to this screen, you will see a button to “Create a new application2
  • Enter the details on this screen
    • Name — Enter a name to your twitter app
    • Description — Provide a short description to your app
    • Website — Normally the website address where you will want your app to be running on (in other words, where you want to display your tweets)
    • Callback URL– Can be left empty
    • Agree to the “Developer Rules of the Road”
    • Enter Captcha

    3

  • Hit “Create your Twitter Application“. You will see a message that your app has been created successfully and you will see you Consumer Key and Consumer Secret.
  • At the bottom of the page. Click “Create my access token“. You will see a message that your token has been successfully created.4
  • Once this is done, go to “OAuth Tool” tab of your app and copy the following fields to be used in your application.
    • Consumer Key
    • Consumer Secret
    • Access Token
    • Access Token Secret

    5

  • You are ready to code some lines in your application to get data from your timeline.

Will be coming up with another post to allow you to connect data with different libraries. In case you face any issue with this, contact me via comments or social media.

#How To?#HTML#oAuth#Twitter#Twitter API#Twitter APIv1.1