Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
New feature (idea for improvement):
The
Session
returned by thelogin_***
methods is stored in the AuthClient itself.This way the AuthClient could use the correct
access_token
inget_user()
,get_settings()
, etc. without requiring the developer to provide the access token as a method parameter. Same for therefresh_token
inrefresh_session()
method.What is the current behavior?
The
Session
is returned from thelogin_***()
methods and it is responsibility of the user application to pass the correct token where needed.What is the new behavior?
The
Session
is still returned by thelogin_**()
methods and the user application may use it if needed.But the AuthClient itself also keeps a handle to the last authenticated session and use its tokens appropriately where needed.
Additional context
My idea is inspired by floris-xlx/supabase_rs#42
There I want to authenticate the user via
supabase.auth().login_***()
and start doingsupabase.insert()/update()/select()/delete()
. By keeping a reference to theSession
the insert/update/... operations could use the correct bearer depending on whether the user is authenticated or not:https://github.com/floris-xlx/supabase_rs/pull/42/files#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759R432-R437