Learn how to use twitter-api-v2 in a user login flow context inside a real world Express application.
This project shows you how to make a simple 3-legged OAuth flow, with both PIN code and callback support.
Install all packages of project, configure .env with required properties, then start TypeScript compiler.
npm i
cp .example.env .env
# ...configure .env with consumer keys
# then start the server
npm run start
.example.env
to .env
file.env
filehttp://localhost:5000/callback
is present in allowed callback URLs, inside your Twitter application settings (in developer portal).Navigate to http://localhost:5000
to test callback-based flow.
Navigate to http://localhost:5000/pin-flow
to test PIN-based flow.
routes/callback.ts
, router.get('/')
) that renders into views/index.ejs
.routes/callback.ts
, router.get('/callback')
route.views/callback.ejs
with access tokens data.routes/pin.ts
, router.get('/pin-flow')
) that renders into views/index.ejs
.routes/pin.ts
, router.get('/validate-pin')
route on button click.