-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor:move_to_extras #315
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,7 +2,6 @@ | |||||||||||||||||||||||||
|
||||||||||||||||||||||||||
import requests | ||||||||||||||||||||||||||
from json_database import JsonStorageXDG | ||||||||||||||||||||||||||
from oauthlib.oauth2 import WebApplicationClient | ||||||||||||||||||||||||||
from ovos_config.locations import get_xdg_cache_save_path | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
from ovos_utils.log import LOG | ||||||||||||||||||||||||||
|
@@ -108,6 +107,7 @@ def refresh_oauth_token(token_id): | |||||||||||||||||||||||||
client_secret = app_data["client_secret"] | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# Perform refresh | ||||||||||||||||||||||||||
from oauthlib.oauth2 import WebApplicationClient | ||||||||||||||||||||||||||
client = WebApplicationClient(client_id, refresh_token=refresh_token) | ||||||||||||||||||||||||||
uri, headers, body = client.prepare_refresh_token_request(token_endpoint) | ||||||||||||||||||||||||||
refresh_result = requests.post(uri, headers=headers, data=body, | ||||||||||||||||||||||||||
Comment on lines
+110
to
113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for missing optional dependency The function should gracefully handle missing oauthlib dependency and provide clear feedback to users. - from oauthlib.oauth2 import WebApplicationClient
- client = WebApplicationClient(client_id, refresh_token=refresh_token)
+ try:
+ from oauthlib.oauth2 import WebApplicationClient
+ client = WebApplicationClient(client_id, refresh_token=refresh_token)
+ except ImportError:
+ LOG.error("oauthlib not installed. Please install 'ovos-utils[oauth]' to use OAuth functionality")
+ return None 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,4 @@ pyee>=8.0.0 | |
combo-lock~=0.2 | ||
rich-click~=1.7 | ||
rich~=13.7 | ||
orjson | ||
langcodes | ||
timezonefinder | ||
oauthlib~=3.2 | ||
orjson |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve error handling for missing optional dependency
The function should provide clear feedback when timezonefinder is not installed.
📝 Committable suggestion