Table of Contents
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
- Go to https://twitter.com/
- 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
- Whilst logged in to Twitter, go to https://apps.twitter.com/
- Click ‘Create New App’
- Enter in a suitable name for your application (e.g. ‘MyFirstApiTests’)
- Enter in a suitable description (e.g. “I am learning how to test APIs in Java with RestAssured”)
- 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/)
- Enter in a suitable Callback URL. (Again, for testing purposes, we can just use http://localhost:10003/
- Agree to the Developer Agreement and click ‘Create your Twitter application’
Create your Keys and Access Tokens
- Click the ‘Keys and Access Tokens’ tab
- Note down your ‘Consumer Key (API Key)’
- 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.
- Scroll down and click ‘Create my access token’
- Note down your ‘Access Token’
- Note down your ‘Access Token Secret’
In the next section, we will start writing code for our API test framework 🙂
Copyright secured by Digiprove © 2018