-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
35 lines (24 loc) · 861 Bytes
/
app.py
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
from flask import Flask, render_template, request
import os
import requests
app = Flask(__name__)
@app.route("/")
def main():
return render_template(
"login_non_js_sdk.html",
app_id=os.getenv("APP_ID"),
redirect_uri="https://localhost:5000/redirect",
)
@app.route("/redirect")
def redirect():
code = request.values.get("code")
url = "https://graph.facebook.com/v6.0/oauth/access_token?client_id={app_id}&redirect_uri={redirect_uri}&client_secret={app_secret}&code={code_parameter}".format(
app_id=os.getenv("APP_ID"),
redirect_uri="https://localhost:5000/redirect",
app_secret=os.getenv("APP_SECRET"),
code_parameter=code,
)
r = requests.get(url)
return r.json()
if __name__ == "__main__":
app.run(ssl_context=("localhost.pem", "localhost-key.pem"), debug=True)