Skip to content
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

🚸 Automatically refresh user tokens #145

Merged
merged 12 commits into from
Feb 18, 2025
Merged

🚸 Automatically refresh user tokens #145

merged 12 commits into from
Feb 18, 2025

Conversation

lazappi
Copy link
Collaborator

@lazappi lazappi commented Feb 12, 2025

Description

Automatically refresh user tokens when trying to connect to an instance with an invalid token instead of failing with an error message:

  • Update lamin_login() to use a stored user handle when none is supplied
  • Move setting the default instance to create_instance() so that it isn't set before a successful connection
  • Add a refresh argument to .get_user_settings() to force ignoring the cache
  • Check if the request failed in api$get_schema() due to an invalid token and if so call lamin_login()
    to refresh the token and make a new request with updated he headers

Checklist

Before review

  • Update and regenerate man pages
  • Add/update tests
  • Add/update examples in vignettes
  • Pass CI checks

Before merge

  • Update architecture vignette
  • Update development vignette
  • Update features in README
  • Update CHANGELOG

If no handle is provided it will now attempt to get one from the user setting file
Previously it could be set without successfully connecting
Forces the function to ignore cached user settings
Check if the request failed due to an invalid token and if so call lamin_login()
to refresh the token and make a new request with updated he headers
When there is no user settings file an anonymous user is returned from .get_user_settings() rather than an error
@lazappi lazappi requested a review from rcannood February 12, 2025 14:02
Copy link
Collaborator

@rcannood rcannood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment, otherwise LGTM!

R/InstanceAPI.R Outdated Show resolved Hide resolved
Co-authored-by: Robrecht Cannoodt <[email protected]>
@lazappi lazappi merged commit fefb385 into main Feb 18, 2025
8 of 9 checks passed
@lazappi lazappi deleted the feature/refresh-token branch February 18, 2025 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants