-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.py
More file actions
41 lines (32 loc) · 1.29 KB
/
Copy pathApp.py
File metadata and controls
41 lines (32 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from flask import Flask, redirect, url_for,jsonify
from werkzeug.contrib.fixers import ProxyFix
from flask_dance.contrib.facebook import make_facebook_blueprint, facebook
app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app)
app.secret_key = "supersekrit" #Just your personal App key.
blueprint = make_facebook_blueprint(
client_id="*************", #Put Your App ID
client_secret="***************", #Put Your App Secret
scope=['user_birthday'] #Define the list you want to access of user's info they will be prompted to allow. Get the list from fb developer's page
)
app.register_blueprint(blueprint, url_prefix="/login")
@app.route("/signup/fb")
def fbSignup():
if not facebook.authorized:
return redirect(url_for("facebook.login"))
else:
return "<h2>logged in to fb</h2>"
@app.route('/',methods=['GET'])
def getUserNameOfGithub():
if facebook.authorized:
resp = facebook.get("/me?fields=gender,birthday")
id = resp.json()["id"]
return resp.json()["birthday"]
else:
return "<h1> you are not logged in</h1>"
@app.after_request
def after(response):
print response.get_data()
return response
if __name__ == "__main__":
app.run(debug=True,ssl_context='adhoc') #Enabling ssl mode for testing as FB doesn't allow http url callbacks.