Skip to content

Commit

Permalink
examples/service-whoami-flask: Fix return types in oauth_callback
Browse files Browse the repository at this point in the history
In my testing, Flask 3.0.0 doesn't accept returning only an integer
(as an error code) in a handler.  A (content, status) tuple does
work.  I don't know if this is a recent change, or if this has always
been broken, but the tuple return should be good for older Flask
versions as well.
  • Loading branch information
rschroll committed Jan 18, 2024
1 parent 8a5fc80 commit e879ab1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/service-whoami-flask/whoami-flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def whoami(user):
def oauth_callback():
code = request.args.get('code', None)
if code is None:
return 403
return "Forbidden", 403

# validate state field
arg_state = request.args.get('state', None)
cookie_state = request.cookies.get(auth.state_cookie_name)
if arg_state is None or arg_state != cookie_state:
# state doesn't match
return 403
return "Forbidden", 403

token = auth.token_for_code(code)
# store token in session cookie
Expand Down

0 comments on commit e879ab1

Please sign in to comment.