From 4f5a6e67afbc3d35994502877600b800c95c7c15 Mon Sep 17 00:00:00 2001 From: samerbam Date: Fri, 25 Aug 2023 19:43:38 -0400 Subject: [PATCH] inital google calendar integration --- application/config.py | 2 ++ application/main.py | 8 +++++++- application/static/index.html | 31 +++++++++++++++++++++++++++++++ application/thermal_print.py | 5 +++-- requirements.txt | 4 ++++ 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/application/config.py b/application/config.py index ddfcd96..7a986d4 100644 --- a/application/config.py +++ b/application/config.py @@ -8,6 +8,8 @@ class Settings(BaseSettings): auth0_api_audience: str auth0_issuer: str auth0_algorithms: str + google_client_id: str + google_client_secret: str class Config: env_file = ".env" diff --git a/application/main.py b/application/main.py index b33b247..cc3adbf 100644 --- a/application/main.py +++ b/application/main.py @@ -55,6 +55,9 @@ class PrintAction(BaseModel): # sentence (prints a custom message) sentence: str = "" +class GoogleUpdate(BaseModel): + code: str + # @app.get("/api/public") # def public(): # """No access token required to access this route""" @@ -66,6 +69,10 @@ class PrintAction(BaseModel): # } # return result +@app.post("/api/google/update") +def write_todos(code: GoogleUpdate, auth_result: str = Security(auth.verify)): + print(code.code) + return {"status": "success"} @app.get('/api/first_run') def first_run(): @@ -101,7 +108,6 @@ def get_todos(date: str = datetime.today().strftime('%Y-%m-%d'), auth_result: st # return auth_result - @app.post("/api/todos/write") def write_todos(todos: TodoList, auth_result: str = Security(auth.verify)): """A valid access token is required to access this route""" diff --git a/application/static/index.html b/application/static/index.html index 633e2c3..5cf8970 100644 --- a/application/static/index.html +++ b/application/static/index.html @@ -18,6 +18,9 @@ + + + @@ -446,6 +449,34 @@ + + + + diff --git a/application/thermal_print.py b/application/thermal_print.py index a196936..127ee22 100644 --- a/application/thermal_print.py +++ b/application/thermal_print.py @@ -30,7 +30,7 @@ # filename = os.path.abspath(os.path.join(WORKING_DIRECTORY, STATIC, 'index.html')) # with open(filename, 'rt') as f: # resp.body = f.read() -from escpos.printer import Usb +from escpos.printer import Usb, Dummy import usb from wonderwords import RandomWord from datetime import datetime @@ -53,8 +53,9 @@ class ThermalPrinter(): # pass except usb.core.NoBackendError as e: print(e) + self.p = Dummy() print("Try running `export DYLD_LIBRARY_PATH=/opt/homebrew/lib` if on m1 mac. source: https://github.com/pyusb/pyusb/issues/355#issuecomment-1062798576") - raise + # raise def print_custom(self, text=""): self.p.set(align="left") diff --git a/requirements.txt b/requirements.txt index a162676..1ce1cfe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,3 +19,7 @@ sniffio==1.3.0 typing_extensions==4.7.1 uvicorn==0.23.2 wonderwords +google-api-python-client +google-auth +google-auth-oauthlib +google-auth-httplib2 \ No newline at end of file