- A simple Python + Flask web app that demonstrates the flow of obtaining a Twitter user OAuth access token.
- Modified to just return your user tokens for the app for simple programs, like https://github.com/Jxck-S/plane-notify
- Doesn't work on windows unless using Linux Subsystem
-
Obtain consumer key and secret from the Twitter Developer portal. The app should be configured to enable Sign in with Twitter. See
twauth-web.py
for more details, but you can either:- add these values to a
config.cfg
file (local deployment); or - set environment variables
TWAUTH_APP_CONSUMER_KEY
andTWAUTH_APP_CONSUMER_SECRET
(cloud deployment)
- add these values to a
-
Setup a pipenv environment, and install dependencies:
pipenv install
pipenv shell
-
Start the app:
python3 ./twauth-web.py
; orgunicorn twauth-web:app
-
Make the site externally accessible port forward, or run a tunnel e.g.
ngrok
for local use, or deploy to a cloud platform such as Heroku (aProcfile
is included), accessing local host will not work. -
Goto the dev portal and go to your app and add your app's callback URL (
https://your-deployed-url/callback
) to the callback URL whitelist setting. -
Go to your deployed URL and sign in your user tokens will be returned for the signed in user to use this app.
Twitter Developer Portal
Flask
python-oauth2
Bootstrap
Original version by Jacob Petrie
https://twitter.com/jaakkosf
https://github.com/jaakko-sf/twauth-web