Git Product home page Git Product logo

twauth-web's Introduction

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 deployment); or
    2. set environment variables TWAUTH_APP_CONSUMER_KEY and TWAUTH_APP_CONSUMER_SECRET (cloud deployment)
  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 Internet-accessible URL - do not attempt to connect via localhost, as this will not work. You can run a tunnel e.g. ngrok for local use, or deploy to a cloud platform 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 (https://your-deployed-url/callback) to the callback URL whitelist setting. Once saved, follow the instructions on the app's web UI 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

twauth-web's People

Contributors

adityaoli avatar andypiper avatar jaakko-sf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twauth-web's Issues

Error R12 timeout on heroku

I am tweeting from a .txt file on behalf of users for 6 hours but after 30 minutes continuously tweeting, I m getting R12 error and server becomes idle.
Plz give solution

Invalid response from Twitter API GET users/show: 403

I have set the environment variables TWAUTH_APP_CONSUMER_KEY and TWAUTH_APP_CONSUMER_SECRET. App permissions are also set to Read and Write and Direct Message. The type of app is a Web App, Automated App, or Bot. The Callback URI / Redirect URL is http://127.0.0.1:5000/callback.

When running the program, I am able to retrieve values for oauth_denied, oauth_token, oauth_verifier, and oauth_store correctly. The browser also redirects to the Twitter authentication screen. However, upon returning to the application, an error occurs. I have tried adjusting the settings, but the issue persists.

Error running app after following steps in README

One line summary of the issue here.

Expected behavior

The app should run after following the steps in the readme and running python3 ./twauth-web.py or gunicorn twauth-web:app.

Actual behavior

Error:

> python3 ./twauth-web.py
Traceback (most recent call last):
  File "/Users/user/Documents/GitHub/twauth-web/./twauth-web.py", line 2, in <module>
    from flask import Flask, render_template, request, url_for
  File "/Users/user/.local/share/virtualenvs/twauth-web-gtoEGit_/lib/python3.11/site-packages/flask/__init__.py", line 17, in <module>
    from werkzeug.exceptions import abort
  File "/Users/user/.local/share/virtualenvs/twauth-web-gtoEGit_/lib/python3.11/site-packages/werkzeug/__init__.py", line 151, in <module>
    __import__('werkzeug.exceptions')
  File "/Users/user/.local/share/virtualenvs/twauth-web-gtoEGit_/lib/python3.11/site-packages/werkzeug/exceptions.py", line 71, in <module>
    from werkzeug.wrappers import Response
  File "/Users/user/.local/share/virtualenvs/twauth-web-gtoEGit_/lib/python3.11/site-packages/werkzeug/wrappers.py", line 27, in <module>
    from werkzeug.http import HTTP_STATUS_CODES, \
  File "/Users/user/.local/share/virtualenvs/twauth-web-gtoEGit_/lib/python3.11/site-packages/werkzeug/http.py", line 1148, in <module>
    from werkzeug.datastructures import Accept, HeaderSet, ETags, Authorization, \
  File "/Users/user/.local/share/virtualenvs/twauth-web-gtoEGit_/lib/python3.11/site-packages/werkzeug/datastructures.py", line 16, in <module>
    from collections import Container, Iterable, MutableSet
ImportError: cannot import name 'Container' from 'collections' (/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/collections/__init__.py

Steps to reproduce the behavior

I'm using Python 3.11 if that helps

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.