Skip to content

Commit

Permalink
fastapi fix server bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jheld committed Dec 11, 2023
1 parent 12cd684 commit ee5a5c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions diycrate/server_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from cheroot.wsgi import Server
from cheroot.ssl.builtin import BuiltinSSLAdapter
import cherrypy
from fastapi import HTTPException
from fastapi import Form, HTTPException
import uvicorn
from diycrate import utils

Expand Down Expand Up @@ -47,7 +47,7 @@ def auth_url(redirect_url: str):

# @bottle_app.route("/authenticate", method="POST")
@app.post("/authenticate")
def authenticate_url(code: str):
def authenticate_url(code: typing.Annotated[str, Form()]):
"""
:return:
Expand All @@ -70,8 +70,8 @@ def authenticate_url(code: str):
# @bottle_app.route("/new_access", method="POST")
@app.post("/new_access")
def new_access(
access_token: typing.Optional[str] = None,
refresh_token: typing.Optional[str] = None,
access_token: typing.Annotated[typing.Optional[str], Form()],
refresh_token: typing.Annotated[typing.Optional[str], Form()],
):
"""
Performs refresh of tokens and returns the result
Expand All @@ -94,7 +94,7 @@ def new_access(
]
# we've done the work, so let's wipe the temporary state adjustment clean
app.oauth._update_current_tokens(None, None)
return json.dumps(str_response)
return str_response
except boxsdk.exception.BoxOAuthException as e:
# we've done the work, so let's wipe the temporary state adjustment clean
app.oauth._update_current_tokens(None, None)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies = [
"bottle>=0.12.8,<=0.13",
"fastapi~=0.104.1",
"uvicorn~=0.24.0",
"python-multipart==0.0.6",
"boxsdk>=2.0,<3.0",
"pyinotify==0.9.6",
"redis~=3.3.0",
Expand Down

0 comments on commit ee5a5c9

Please sign in to comment.