How to Create Multiple Bots With a Single Twitter Developer Account
--
One of the issues I encountered while building my first Twitter bot was that the bot was tweeting from my personal account instead of my bot account. After doing some research, I realized that this is a common issue in the Developer Community.
But unfortunately, the Twitter Community answer I came across wasn’t really explanatory for beginners. A few weeks after managing to figure this out on my own, someone asked a similar question on Botmaker’s Slack Channel and that was my cue to write this article.
The proposed solution from this screenshot was to apply for a new developer account for the bot, but you will come to know that this isn’t practical in the long run.
And why is that? 👇
As a hobbyist who wants to build many Twitter bots for fun or as a professional who creates Twitter bots for various organizations, applying for a new developer account with each bot you build is highly impractical and can be time and effort draining.
As some people have pointed out in the comments, it is also against Twitter’s rules and regulations to have multiple developer accounts.
“A single Twitter user can have a single developer account or can be a member of a team account”.
To make things easier for developers who want to create multiple Twitter bots, I’ll be sharing a step-by-step guide on how to associate a single Twitter Developer account with multiple bots.
If you don’t already have a Twitter Developer account, I wrote a simple guide on how to create one in my previous article.
Terminologies
To better understand the rest of this article, there are some Twitter developer terminologies you need to familiarize yourself with.
- Projects: They can be used to organize your work based on how you intend to use the Twitter API, manage your access to the API, and also monitor usage. Each Project contains an App, with which you can generate authentication credentials.
- App: An App is any program, tool, or bot, that makes API calls. Twitter grants authentication credentials to apps, not accounts. Therefore, you need to create an app to be able to make API calls.
- Bearer Token: This method is specifically for developers who need read-only access to the Twitter App. It is specific to an App, and it is used to authenticate requests on behalf of your App.
- Oauth Key & Oauth Token Secret: Also called the Access Token and Access Secret respectively, they are user-specific credentials used to authenticate OAuth 1.0a API requests.
- Consumer Key & Consumer Secret: Also called the API Key and API Secret, it is similar to your Twitter account’s email and password. With these two tokens, you can perform any read and write permission on an individual’s account. This is what we need to create a program that tweets from a bot’s account.
You can generate your own consumer key and consumer secret if you would like your app to make requests on behalf of the same Twitter account associated with your developer account on the Twitter developer app’s details page.
However, if you’d like to make requests on behalf of another account, you’ll need to follow the steps below.
- Visit the URL “https://twitter.com/oauth/request_token?oauth_consumer_key=<YOUR CONSUMER KEY>&oauth_callback=oob” on the account associated with your Twitter Developer App. That is, the account used to request Twitter Developer access.
Something like this should show up in your browser. It’s a temporary token and will expire after using it once. Copy the tokens and paste them somewhere.
- Now, log in to your bot account, then paste this URL in the browser “https://twitter.com/oauth/authenticate?oauth_token=<NEWLY GENERATED TOKEN>”. Replace the oauth_token in the link with the newly generated one you copied earlier.
Now, click on Authorize app to grant access. After clicking on that, you should see an autogenerated 7 digit number. Copy that number somewhere.
Finally, visit the URL below on your browser, and you’ll get the OAuth tokens required to post via your bot account.
All the steps we highlighted above are part of the 3-legged OAuth flow required to access a third-party Twitter account. Although slightly different, this method can also be used to receive read & write permissions via a Web App.
If you found this post helpful and would like to support me, you can some tokens to my Ethereum address tjelailah.eth (0x66fe4806cD41BcD308c9d2f6815AEf6b2e38f9a3)
References
https://twitter.com/filtertrend
https://blog.formpl.us/analyzing-tweeps-favorite-spotify-podcasts-a29ba6b11fbd
https://developer.twitter.com/en/docs/projects/overview
https://developer.twitter.com/en/docs/apps/overview
https://developer.twitter.com/en/docs/authentication/oauth-2-0
https://developer.twitter.com/en/docs/authentication/oauth-1-0a
https://developer.twitter.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens