Skip to content

Instantly share code, notes, and snippets.

@singingwolfboy
Created November 17, 2015 02:11
Show Gist options
  • Save singingwolfboy/df648957e962c345b561 to your computer and use it in GitHub Desktop.
Save singingwolfboy/df648957e962c345b561 to your computer and use it in GitHub Desktop.
from flask import Flask, redirect, url_for
from flask_dance.contrib.twitter import make_twitter_blueprint, twitter
app = Flask(__name__)
app.secret_key = "supersekrit"
blueprint = make_twitter_blueprint(
api_key="my-key-here",
api_secret="my-secret-here",
)
app.register_blueprint(blueprint, url_prefix="/login")
@app.route("/")
def index():
if not twitter.authorized:
return redirect(url_for("twitter.login"))
resp = twitter.get("account/settings.json")
assert resp.ok
return "You are @{screen_name} on Twitter".format(screen_name=resp.json()["screen_name"])
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment