Update app.py
Browse files
app.py
CHANGED
@@ -31,40 +31,25 @@ def login():
|
|
31 |
return redirect("https://accounts.google.com/o/oauth2/auth?response_type=code&client_id={}&redirect_uri=http://localhost:3000/callback&scope=email%20profile&access_type=offline".format(CLIENT_ID))
|
32 |
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
#
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
# return jsonify({"output": output})
|
55 |
-
|
56 |
-
|
57 |
-
# @app.route("/query_emotion")
|
58 |
-
# def emotion():
|
59 |
-
# start = request.args.get("start")
|
60 |
-
# end = request.args.get("end")
|
61 |
-
|
62 |
-
# print(start)
|
63 |
-
# print(end)
|
64 |
-
|
65 |
-
# output = query_emotion(int(start), int(end))
|
66 |
-
|
67 |
-
# return jsonify({"output": output})
|
68 |
|
69 |
|
70 |
if __name__ == "__main__":
|
@@ -73,25 +58,7 @@ if __name__ == "__main__":
|
|
73 |
|
74 |
|
75 |
|
76 |
-
# @app.route("/callback")
|
77 |
-
# def callback():
|
78 |
-
# code = request.args.get("code")
|
79 |
-
# token_response = grequests.post("https://oauth2.googleapis.com/token",
|
80 |
-
# data={
|
81 |
-
# "code": code,
|
82 |
-
# "client_id": CLIENT_ID,
|
83 |
-
# "client_secret": CLIENT_SECRET,
|
84 |
-
# "redirect_uri": "http://localhost:3000/callback",
|
85 |
-
# "grant_type": "authorization_code"
|
86 |
-
# })
|
87 |
-
# token_data = token_response.json()
|
88 |
-
# access_token = token_data.get("access_token")
|
89 |
-
# id_info = id_token.verify_oauth2_token(token_data.get("id_token"), grequests.Request(), CLIENT_ID)
|
90 |
-
|
91 |
-
# # Store user information in session
|
92 |
-
# session['user'] = id_info
|
93 |
|
94 |
-
# return redirect(url_for("profile"))
|
95 |
|
96 |
# @app.route("/profile")
|
97 |
# def profile():
|
|
|
31 |
return redirect("https://accounts.google.com/o/oauth2/auth?response_type=code&client_id={}&redirect_uri=http://localhost:3000/callback&scope=email%20profile&access_type=offline".format(CLIENT_ID))
|
32 |
|
33 |
|
34 |
+
@app.route("/callback")
|
35 |
+
def callback():
|
36 |
+
code = request.args.get("code")
|
37 |
+
token_response = grequests.post("https://oauth2.googleapis.com/token",
|
38 |
+
data={
|
39 |
+
"code": code,
|
40 |
+
"client_id": CLIENT_ID,
|
41 |
+
"client_secret": CLIENT_SECRET,
|
42 |
+
"redirect_uri": "http://localhost:3000/callback",
|
43 |
+
"grant_type": "authorization_code"
|
44 |
+
})
|
45 |
+
token_data = token_response.json()
|
46 |
+
access_token = token_data.get("access_token")
|
47 |
+
id_info = id_token.verify_oauth2_token(token_data.get("id_token"), grequests.Request(), CLIENT_ID)
|
48 |
+
|
49 |
+
# Store user information in session
|
50 |
+
session['user'] = id_info
|
51 |
+
|
52 |
+
return redirect(url_for("profile"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
|
55 |
if __name__ == "__main__":
|
|
|
58 |
|
59 |
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
|
|
62 |
|
63 |
# @app.route("/profile")
|
64 |
# def profile():
|