Generate your keys and tokens for the Twitter API
Before you create a Twitter bot, you first need to generate all the required keys and tokens.
- Step 1: Head over to the Twitter Developer Platform
- Step 2: Set up user authentication settings
- Step 3: Generate Access Token and Secret
You will first need a regular Twitter account. Once you have one, you can go to the Twitter Developer Platform.
Once there, click on the Developer Portal button next to your image at the top right hand corner.
Twitter may prompt you to have a valid email and/or phone number on your account. It may also ask you why you want to use the Twitter API, you can just enter 'exploring the API'. Enter these in. You should eventually arrive at this page.
Enter a name for your application, and click Get Keys. You should be shown a page similar to this, with an API key, API key secret, and Bearer Token. Copy them all into a safe place. Then click Dashboard.
On the dashboard, click the cog icon under Project App.
Then click on Set Up, under User Authentication Settings.
This will take you to a page where we can change a number of settings. Under App permissions, we will select Read and Write, under Type of App we will select Web App, Automated App or Bot.
Click on the Keys and tokens tab.
Once there, click on the Generate button for Access Token and Secret. In the image below, it says Regenerate, this is because I had previously generated keys.
This will generate your Access Token and Access Token Secret. Save these in a safe place.
Once you have done this, the message below the Access Token and Secret should say Created with Read and Write permissions. If it doesn't, this means that you did not click Read and Write in step 2.
Now you should be done! You should have a API Key, API Key Secret, Bearer Token, Access Token and Access Token Secret.
You would have also generated a Client ID and Client Secret. You will not need these for the following tutorials on creating twitter bots.