Skip to content

Commit

Permalink
port shared oauth db utils (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl authored Dec 5, 2022
1 parent 7708c1e commit 6ae7996
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 35 deletions.
2 changes: 1 addition & 1 deletion ovos_local_backend/backend/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
35 changes: 2 additions & 33 deletions ovos_local_backend/database/oauth.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6ae7996

Please sign in to comment.