In this tutorial, we will learn how to set up Twitter as an authentication provider for Conduit.
Prerequisites
Before you begin, you will need to have a Twitter account and a Twitter app. If you don't have a Twitter account, you can create one here.
If you don't have a Twitter app, you can create one here.
Setting up Twitter
Step 1: Create a Twitter app
- Go to the Twitter Developer Portal and log in with your Twitter account.
- Click on the Create an app button.
- Fill in the required details and click on the Create button.
Step 2: Configure the Twitter app
- Go to the Keys and tokens tab and copy the API key and API secret key.
- Go to the Settings tab and enable Allow this application to be used to Sign in with Twitter.
- Go to the App permissions tab and enable the permissions you want to use.
Step 3: Configure the Twitter provider
- Go to the Authentication tab and click on the SIGN IN METHODS.
- Select Twitter from the list of providers.
- Paste the API key and API secret key from the Keys and tokens tab of the Twitter app.
- Enable the twitter provider and click on the Save button.
Authenticate with Twitter
To begin authenticating with Twitter you request a redirect url with the proper scopes
Request
curl --location --request GET 'http://localhost:3000/authentication/init/twitter'
Response
{
"result": "https://twitter.com/i/oauth2/authorize?client_id=ZURSUXNqX2Q5T1RmcDNCenJBZE46MTpjaQ&redirect_uri=http://localhost:3000/hook/authentication/twitter&response_type=code&response_mode=query&scope=tweet.read%20users.read%20offline.access&code_challenge=LBVjPhkdXdFvZZdn3OvsyvwZAQRrr05-N_oprH3EBWo&code_challenge_method=S256&state=006f65b0-a26c-4a69-aa29-6145d8506cc6"
}
Open a browser and navigate to the url returned to you from Conduit. Now the /hook/authentication route has been triggered. Once your browser has been redirected, your authentication has been completed.