Skip to content

Commit

Permalink
Merge pull request #300 from OpenVoiceOS/release-0.4.1a1
Browse files Browse the repository at this point in the history
Release 0.4.1a1
  • Loading branch information
JarbasAl authored Nov 20, 2024
2 parents 3bfcde3 + d63e432 commit 843d771
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 13 deletions.
14 changes: 3 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
# Changelog

## [0.3.8a2](https://github.com/OpenVoiceOS/ovos-utils/tree/0.3.8a2) (2024-11-19)
## [0.4.1a1](https://github.com/OpenVoiceOS/ovos-utils/tree/0.4.1a1) (2024-11-20)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-utils/compare/0.3.8a1...0.3.8a2)
[Full Changelog](https://github.com/OpenVoiceOS/ovos-utils/compare/0.4.0...0.4.1a1)

**Merged pull requests:**

- feature: geolocation utils extracted from backend-client [\#296](https://github.com/OpenVoiceOS/ovos-utils/pull/296) ([JarbasAl](https://github.com/JarbasAl))

## [0.3.8a1](https://github.com/OpenVoiceOS/ovos-utils/tree/0.3.8a1) (2024-11-11)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-utils/compare/0.3.7...0.3.8a1)

**Merged pull requests:**

- Update ovos-bus-client requirement from \<1.0.0,\>=0.0.8 to \>=0.0.8,\<2.0.0 in /requirements [\#294](https://github.com/OpenVoiceOS/ovos-utils/pull/294) ([dependabot[bot]](https://github.com/apps/dependabot))
- move oauth utils to ovos-utils and deprecate backend-client [\#299](https://github.com/OpenVoiceOS/ovos-utils/pull/299) ([JarbasAl](https://github.com/JarbasAl))



Expand Down
70 changes: 70 additions & 0 deletions ovos_utils/oauth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from json_database import JsonStorageXDG
from ovos_config.locations import get_xdg_cache_save_path


class OAuthTokenDatabase(JsonStorageXDG):
""" This helper class creates ovos-config-assistant/ovos-backend-manager compatible json databases
This allows users to use oauth even when not using a backend"""

def __init__(self):
super().__init__("ovos_oauth", xdg_folder=get_xdg_cache_save_path())

def add_token(self, token_id, token_data):
self[token_id] = token_data

def update_token(self, token_id, token_data):
self.add_token(token_id, token_data)

def get_token(self, token_id):
return self.get(token_id)

def delete_token(self, token_id):
if token_id in self:
self.pop(token_id)
return True
return False

def total_tokens(self):
return len(self)


class OAuthApplicationDatabase(JsonStorageXDG):
""" This helper class creates ovos-config-assistant/ovos-backend-manager compatible json databases
This allows users to use oauth even when not using a backend"""

def __init__(self):
super().__init__("ovos_oauth_apps", xdg_folder=get_xdg_cache_save_path())

def add_application(self, oauth_service,
client_id, client_secret,
auth_endpoint, token_endpoint, callback_endpoint, scope,
shell_integration=True):
self[oauth_service] = {"oauth_service": oauth_service,
"client_id": client_id,
"client_secret": client_secret,
"auth_endpoint": auth_endpoint,
"token_endpoint": token_endpoint,
"callback_endpoint": callback_endpoint,
"scope": scope,
"shell_integration": shell_integration}

def get_application(self, oauth_service):
return self.get(oauth_service)

def update_application(self, oauth_service,
client_id, client_secret,
auth_endpoint, token_endpoint,
callback_endpoint, scope, shell_integration=True):
self.add_application(oauth_service,
client_id, client_secret,
auth_endpoint, token_endpoint,
callback_endpoint, scope, shell_integration)

def delete_application(self, oauth_service):
if oauth_service in self:
self.pop(oauth_service)
return True
return False

def total_apps(self):
return len(self)
4 changes: 2 additions & 2 deletions ovos_utils/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# START_VERSION_BLOCK
VERSION_MAJOR = 0
VERSION_MINOR = 4
VERSION_BUILD = 0
VERSION_ALPHA = 0
VERSION_BUILD = 1
VERSION_ALPHA = 1
# END_VERSION_BLOCK

0 comments on commit 843d771

Please sign in to comment.