Skip to content

Instantly share code, notes, and snippets.

@Bachmann1234
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bachmann1234/fec472272ce79bb707d7 to your computer and use it in GitHub Desktop.
Save Bachmann1234/fec472272ce79bb707d7 to your computer and use it in GitHub Desktop.
facebook flask-dance.py
from flask import Flask, url_for, redirect
from flask_dance.consumer import OAuth2ConsumerBlueprint
app = Flask(__name__)
app.secret_key = "<ISHOULDBESOMETHING>"
batman_example = OAuth2ConsumerBlueprint(
"batman-example", __name__,
client_id="<CLIENT_ID>",
client_secret="<SECRET>",
base_url="https://graph.facebook.com",
authorization_url="https://www.facebook.com/dialog/oauth",
token_url="https://graph.facebook.com/oauth/access_token",
)
app.register_blueprint(batman_example, url_prefix="/login")
@app.route("/")
def index():
if not batman_example.session.authorized:
return redirect(url_for("batman-example.login"))
resp = batman_example.session.get("me")
assert resp.ok
return resp.text
if __name__ == "__main__":
app.run(port=8080, debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment