Getting Started with the Twitter API

Introduction

In this blog series, we will be using the Twitter API as an example for creating and running our RESTful API tests against.

Twitter requires all users of its API to authenticate via OAuth 1.

OAuth 1 Parameters

In order for a user to authenticate with the Twitter API via OAuth 1, they must have the information for all of the following parameters, specific to your individual account…

  • Consumer Key
  • Consumer Secret
  • Token
  • Token Secret

Let’s get started below 🙂

Get the Twitter OAuth Parameters

Create a Twitter Account

  1. Go to https://twitter.com/
  2. Either login with an existing Twitter account, or click ‘Sign Up’ and create a new one with a valid email address

Create an Application to use Twitter APIs

  1. Whilst logged in to Twitter, go to https://apps.twitter.com/
  2. Click ‘Create New App’
  3. Enter in a suitable name for your application (e.g. ‘MyFirstApiTests’)
  4. Enter in a suitable description (e.g. “I am learning how to test APIs in Java with RestAssured”)
  5. Enter in a suitable website, for where in the real world, you would use the Twitter APIs in your own web application. (For testing purposes, you can just enter a sample site, e.g. http://localhost:10003/)
  6. Enter in a suitable Callback URL. (Again, for testing purposes, we can just use http://localhost:10003/
  7. Agree to the Developer Agreement and click ‘Create your Twitter application’

Create your Keys and Access Tokens

  1. Click the ‘Keys and Access Tokens’ tab
  2. Note down your ‘Consumer Key (API Key)’
  3. Note down your ‘Consumer Secret (API Secret)’

Access Token

This access token can be used to make API requests on your own account’s behalf. Do not share your Access Token Secret with anyone.

  1. Scroll down and click ‘Create my access token’
  2. Note down your ‘Access Token’
  3. Note down your ‘Access Token Secret’

In the next section, we will start writing code for our API test framework 🙂

 

Digiprove sealCopyright secured by Digiprove © 2018
Liked it? Take a second to support Thomas on Patreon!

Previous Article

Next Article

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.