October 29, 2017

Tinkering with Twitter: Getting credentials, consumerKey, accessToken

This is Part Two of a multi-part blog series on putting together a basic API test framework for the Twitter Search API. Care to go back to the beginning

In order to be able to programmatically interact with Twitter through their APIs, you need an:

  •  OAUTH Consumer Key
  • Consumer Secret
  • Access Token
  • Access Token Secret 
Then, you need to place them in a Twitter4J Properties file.

The file will look something like this:



twitter4J.properties
debug=true oauth.consumerKey=*********************
oauth.consumerSecret=****************************************** 
oauth.accessToken=**************************************************
oauth.accessTokenSecret=******************************************  

.... Replace the lines of asterisks with the actual values once you get them.

How do we get our own OAUTH credentials for Twitter?


To be able to access Twitter APIs, you need to:

1) Create a Twitter Account: 
  • Go to Twitter.com and create an account for yourself. 
2) Create a Twitter App to use the Twitter API
  • Go to https://apps.twitter.com/ and choose to Create a new app.
  • Come up with a name and a description of how your project will be using the Twitter APIs. I called mine: "Tinkering With Twitter".
  • Are you creating a full blown app that will interact with a website you are creating? Enter it here. If not, enter a placeholder URL. 
  • Your app will be accessible from https://apps.twitter.com/
3) Find your new OAUTH Credentials.
  • Go to https://apps.twitter.com/
  • Select the link on the Dashboard to enter your Twitter App.
  • Next to "Consumer Key and Access Key" select the link for "manage keys and access tokens". 
There, you will see your:


  • Consumer Key
  • Consumer Secret
  • Access Token
  • Access Secret
Record these values, but don't share them, especially the secrets! You will be inputting them in a properties file once we set up the project. 

With the next blog entry, we will talk about how to search with Twitter. Or if you want, you can jump right to the source code


Happy Testing!




-T.J. Maher
Twitter | LinkedIn | GitHub

// Sr. QA Engineer, Software Engineer in Test, Software Tester since 1996.
// Contributing Writer for TechBeacon.
// "Looking to move away from manual QA? Follow Adventures in Automation on Facebook!"

1 comment:

koe61831 said...

When it comes to guilt, I can always advise something, for example, this site https://us.calmerry.com/blog/self-esteem/why-do-i-feel-guilty-for-no-reason/ has a blog about why I feel guilty about everything, it has all the details, and, fortunately, there is excellent online therapy with good psychotherapists .