-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: token refresh #818
feat: token refresh #818
Conversation
def email_login(self) -> None: | ||
username = os.getenv("GALILEO_USERNAME") | ||
password = os.getenv("GALILEO_PASSWORD") | ||
res = requests.post( | ||
f"{config.api_url}/login", | ||
data={ | ||
"username": username, | ||
"password": password, | ||
"auth_method": "email", | ||
}, | ||
headers={"X-Galileo-Request-Source": "dataquality_python_client"}, | ||
) | ||
if res.status_code != 200: | ||
raise GalileoException( | ||
( | ||
f"Issue authenticating: {res.json()['detail']} " | ||
"If you need to reset your password, " | ||
f"go to {config.api_url.replace('api', 'console')}/forgot-password" | ||
) | ||
) | ||
|
||
access_token = res.json().get("access_token") | ||
config.token = access_token | ||
config.update_file_config() |
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.
i really don't like that we did this in auth
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.
➕
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #818 +/- ##
==========================================
+ Coverage 86.57% 86.59% +0.02%
==========================================
Files 196 196
Lines 15728 15767 +39
==========================================
+ Hits 13617 13654 +37
- Misses 2111 2113 +2 ☔ View full report in Codecov by Sentry. |
Shortcut Ticket
https://app.shortcut.com/galileo/story/10174/dq-api-client-token-refresh
Drew Inspiration from
We should have an automatic token refresh similar to LLM Monitor and Prompt: https://github.com/rungalileo/llm-monitor/blob/1a42e5275dc5d4bb6b11219284269f44b02cab3b/llm_monitor/utils/api_client.py#L72-L89
Testing
https://fmpm.dev/mocking-auth0-tokens
Local example
My local token was expired but it used the local env to refresh succesfully.