From 468406fae8f93cf274052c126c32e7ca3eeb578e Mon Sep 17 00:00:00 2001 From: jarbasai Date: Mon, 5 Dec 2022 02:26:56 +0000 Subject: [PATCH] port shared oauth db utils --- ovos_local_backend/backend/auth.py | 2 +- ovos_local_backend/database/oauth.py | 35 ++-------------------------- requirements/requirements.txt | 2 +- 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/ovos_local_backend/backend/auth.py b/ovos_local_backend/backend/auth.py index 61e62ca..581a4bf 100644 --- a/ovos_local_backend/backend/auth.py +++ b/ovos_local_backend/backend/auth.py @@ -20,7 +20,7 @@ from ovos_local_backend.backend import API_VERSION from ovos_local_backend.backend.decorators import noindex, requires_auth -from ovos_local_backend.database.oauth import OAuthTokenDatabase, OAuthApplicationDatabase +from ovos_backend_client.database import OAuthTokenDatabase, OAuthApplicationDatabase from ovos_local_backend.utils import nice_json os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' diff --git a/ovos_local_backend/database/oauth.py b/ovos_local_backend/database/oauth.py index 175cafd..e61617e 100644 --- a/ovos_local_backend/database/oauth.py +++ b/ovos_local_backend/database/oauth.py @@ -1,33 +1,2 @@ -from json_database import JsonStorageXDG - - -class OAuthTokenDatabase(JsonStorageXDG): - def __init__(self): - super().__init__("ovos_oauth") - - def add_token(self, oauth_service, token_data): - self[oauth_service] = token_data - - def total_tokens(self): - return len(self) - - -class OAuthApplicationDatabase(JsonStorageXDG): - def __init__(self): - super().__init__("ovos_oauth_apps") - - def add_application(self, oauth_service, - client_id, client_secret, - auth_endpoint, token_endpoint, refresh_endpoint, - callback_endpoint, scope): - self[oauth_service] = {"oauth_service": oauth_service, - "client_id": client_id, - "client_secret": client_secret, - "auth_endpoint": auth_endpoint, - "token_endpoint": token_endpoint, - "refresh_endpoint": refresh_endpoint, - "callback_endpoint": callback_endpoint, - "scope": scope} - - def total_apps(self): - return len(self) +# backwards compat import +from ovos_backend_client.database import OAuthTokenDatabase, OAuthApplicationDatabase diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 5f22f5f..e62d05d 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -8,5 +8,5 @@ ovos-stt-plugin-server geocoder timezonefinder requests_cache -ovos_backend_client~=0.0, >=0.0.5a3 +ovos-backend-client~=0.0, >=0.0.6a10 oauthlib~=3.0 \ No newline at end of file