Bots on Twitter are what makes the conversation on Twitter so lively. There are many unique bots on Twitter, from tiny aquariums to warning you of sewer overflow in NYC. Bots make Twitter unique and engaging.
When our team launched the manage Tweets endpoints, I built a bot @FactualCat that Tweeted cat facts daily. This bot used OAuth 1.0a to authenticate, but I wanted to challenge myself to create a bot that used OAuth 2.0 Authorization Code Flow with PKCE.
Since I was used to the OAuth 1.0a authentication flow, I had a hard time figuring out exactly what I needed to do to authenticate on behalf of my bot and get it running so that it could make requests regularly.
This code sample will allows you to make a bot similar to @Factual__Dog, a bot that Tweets dogs facts twice daily. By the end of this tutorial, you should be able to create a Twitter bot that utilizes OAuth 2.0 Authorization Code Flow with PKCE for authentication.
- A developer account.
- If you don’t already have access to the Twitter API, you can sign up for a developer account.
- A Project in the developer portal
- An App containing the credentials required to use the Twitter API
- OAuth 2.0 turned on in your App’s authentication settings
To learn more about this code sample, check out our tutorial which walks you through the steps to create this bot.