Skip to content

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

twauth-web

A simple Python + Flask web app that demonstrates the flow of obtaining a Twitter user OAuth access token.

Setup

  1. 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:
    1. add these values to a config.cfg file (local); or
    2. set environment variables TWAUTH_APP_CONSUMER_KEY and TWAUTH_APP_CONSUMER_SECRET (cloud or local)
  2. Setup a pipenv environment, and install dependencies:
    1. pipenv install
    2. pipenv shell
  3. Start the app:
    1. python3 ./twauth-web.py; or
    2. gunicorn twauth-web:app

Note: the app must have an externally-accessible URL (i.e do not attempt to connect via localhost). You can run a tunnel e.g. ngrok for local use, or deploy to a cloud environment such as Heroku (a Procfile is included).

Open a browser window on your demo app's external URL. Don't click the buttons yet!

Finally, revisit the dev portal, and add your app's callback URL (http[s]://your-deployed-url/callback) to the callback URL whitelist setting, before attempting to click through the demo pages.

Reference

Twitter Developer Portal
Flask
python-oauth2
Bootstrap

Credits

Original version by Jacob Petrie
https://twitter.com/jaakkosf
https://github.com/jaakko-sf/twauth-web

About

A simple Python Flask web app that demonstrates the flow of obtaining a Twitter user OAuth access token

Topics

Resources

Code of conduct

Stars

112 stars

Watchers

12 watching

Forks

Used by

Contributors

Languages