aagoluoglu commited on
Commit
3ab3d9f
·
verified ·
1 Parent(s): de02c18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -36
app.py CHANGED
@@ -74,42 +74,42 @@ CLIENT_SECRET = os.environ.get("GOOGLE_CLIENT_SECRET")
74
  def index():
75
  return render_template("index.html")
76
 
77
- @app.route("/login")
78
- def login():
79
- return redirect("https://accounts.google.com/o/oauth2/auth?response_type=code&client_id={}&redirect_uri=http://localhost:5000/callback&scope=email%20profile&access_type=offline".format(CLIENT_ID))
80
-
81
- @app.route("/callback")
82
- def callback():
83
- code = request.args.get("code")
84
- token_response = grequests.post("https://oauth2.googleapis.com/token",
85
- data={
86
- "code": code,
87
- "client_id": CLIENT_ID,
88
- "client_secret": CLIENT_SECRET,
89
- "redirect_uri": "http://localhost:3000/callback",
90
- "grant_type": "authorization_code"
91
- })
92
- token_data = token_response.json()
93
- access_token = token_data.get("access_token")
94
- id_info = id_token.verify_oauth2_token(token_data.get("id_token"), grequests.Request(), CLIENT_ID)
95
-
96
- # Store user information in session
97
- session['user'] = id_info
98
-
99
- return redirect(url_for("profile"))
100
-
101
- @app.route("/profile")
102
- def profile():
103
- user = session.get('user')
104
- if user:
105
- return render_template("profile.html", user=user)
106
- else:
107
- return "User not authenticated"
108
-
109
- @app.route("/logout")
110
- def logout():
111
- session.pop('user', None)
112
- return redirect(url_for("index"))
113
 
114
  if __name__ == "__main__":
115
  app.run(debug=True)
 
74
  def index():
75
  return render_template("index.html")
76
 
77
+ # @app.route("/login")
78
+ # def login():
79
+ # return redirect("https://accounts.google.com/o/oauth2/auth?response_type=code&client_id={}&redirect_uri=http://localhost:5000/callback&scope=email%20profile&access_type=offline".format(CLIENT_ID))
80
+
81
+ # @app.route("/callback")
82
+ # def callback():
83
+ # code = request.args.get("code")
84
+ # token_response = grequests.post("https://oauth2.googleapis.com/token",
85
+ # data={
86
+ # "code": code,
87
+ # "client_id": CLIENT_ID,
88
+ # "client_secret": CLIENT_SECRET,
89
+ # "redirect_uri": "http://localhost:3000/callback",
90
+ # "grant_type": "authorization_code"
91
+ # })
92
+ # token_data = token_response.json()
93
+ # access_token = token_data.get("access_token")
94
+ # id_info = id_token.verify_oauth2_token(token_data.get("id_token"), grequests.Request(), CLIENT_ID)
95
+
96
+ # # Store user information in session
97
+ # session['user'] = id_info
98
+
99
+ # return redirect(url_for("profile"))
100
+
101
+ # @app.route("/profile")
102
+ # def profile():
103
+ # user = session.get('user')
104
+ # if user:
105
+ # return render_template("profile.html", user=user)
106
+ # else:
107
+ # return "User not authenticated"
108
+
109
+ # @app.route("/logout")
110
+ # def logout():
111
+ # session.pop('user', None)
112
+ # return redirect(url_for("index"))
113
 
114
  if __name__ == "__main__":
115
  app.run(debug=True)