ProgrammingTechnology

Generate Twitter Consumer Key and Access Token

Twitter API Key – How to Generate Twitter Consumer Key and Access Token

In order to create a Twitter App, you always need Twitter API Keys (consisting of Twitter Consumer Key and Twitter Access Token). At first, I was including the information of how to generate twitter API keys along with a different article about creating a twitter bot, something that many find useful when it comes to marketing on the platform. Indeed, alongside methods outlined through Twesocial reviews, people will often find bots useful for quality of life improvements when it comes to their marketing campaigns.

With this in mind, I later realized that this information is worthy of its own article and thought that if I’m going to refer to these API Keys many times in my upcoming articles then I should better let my readers know what actually Twitter Consumer Keys and Access Tokens are and how you can generate them.

But first, let me clarify very briefly the differences between Twitter Consumer Key, Consumer Key Secret and Twitter Access Token and Access Token Secret.

Twitter Consumer Key and Consumer Key Secret

Consumer Key

Every application needs an identification. Just like a username for any website. Similarly, the consumer key acts like a username for your app. Any website, whose API you’re going to use (in this case, Twitter) needs this identification to provide you access. So plainly put, Twitter Consumer Key is akin to what usernames are to any membership website.

Consumer Key Secret

This is just like a password for your app to access the API. This secret key is used to authenticate with the authentication server. In our case, Twitter. Needless to say that you need to protect your consumer key secret just like you protect your normal password.

Twitter Access Token and Access Token Secret

Access Token

Once you get authenticated using your consumer key and secret, you are provided with the access token. Access token contains information about the privileges and the rights particular app has.

Access Token Secret

Again, just like the consumer key secret, access token secret is sent with the access token and acts like a password to your access token.

How To Generate Twitter Consumer Key and Consumer Secret Codes

To generate your own Twitter Consumer Key, Consumer Secret codes, follow the below steps:

  1. Log in to apps.twitter.com. The same Twitter credentials will work here.
  2. Click Create New App button.
    Twitter API Key - Create New App
  3. Enter the name of your application in the Name field. This should be unique.
  4. Enter description of your app in the Description field.
  5. Enter the URL of your website. This is the website where your app will reside so that your users can download or gain more information about your app. In case you don’t have a website then enter a placeholder for time being. But remember, in the long run, in case you want your app to be publicized, you may need to enter your website’s URL.
  6. Enter the Callback URL. This is the URL users are redirected to when successfully authenticated. Since this is an optional field, you can also leave it blank.
  7. Accept Twitter’s terms and conditions
  8. Click Create your twitter application.
    Twitter API Key - Create an Application
  9. On the very next screen that shows up, go to Keys and Access Tokens tab to get your Consumer API Key and Consumer Secret. Remember, your Consumer Secret is a “Secret Code” and should not be shared with anyone.
    Twitter Consumer Key - Twitter Consumer Key Secret

How to Generate Twitter Access Token and Access Token Secret

Once you have your own Twitter Consumer API Key and Consumer Secret codes, let’s now see how you can generate Access Tokens and Access Tokens Secret.

While staying in the Keys and Access Tokens tab mentioned above, do the following:

  1. Right at the very bottom of the screen, in the Token Actions section, click the button, Create My Access Token.
  2. The screen will be refreshed and your access token is created now.
  3. To check your tokens, scroll below and you will see your tokens in Your Access Token section.
    Twitter Access Token Secret
  4. Your Access Token Secret is your secret code and should not be shared with anyone. Do I need to emphasize any more?

Final Word

So above is the way you can generate your consumer API keys for your apps to integrate with Twitter API. You may need to refer to this method not once but every time you create a new app to integrate and fetch Twitter data via Twitter API.

Do let me know in the comments section if this article was helpful or if I missed anything.

One thought on “Generate Twitter Consumer Key and Access Token

Comments are closed.