-
Notifications
You must be signed in to change notification settings - Fork 174
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
Use provided JWT
to make supabase client object logged with this JWT
#70
Comments
I'm currently working on a PR to add dataclasses to the responses and synchronize the functionalities between gotrue-py and gotrue-js, that functionality that you mention is already in gotrue-js so I will add it to gotrue-py in the PR. |
When I say, "currently", it is literal 😅. Here you have a preview def set_auth(self, access_token: str) -> Session:
"""Overrides the JWT on the current client. The JWT will then be sent in
all subsequent network requests.
Parameters
----------
access_token : str
A JWT token
Returns
-------
response : Session
A logged-in session
Raises
------
error : ApiError
If an error occurs
"""
session = Session(
access_token=access_token,
token_type="bearer",
user=None,
expires_in=None,
expires_at=None,
refresh_token=None,
provider_token=None,
)
if self.current_session:
session.expires_in = self.current_session.expires_in
session.expires_at = self.current_session.expires_at
session.refresh_token = self.current_session.refresh_token
session.provider_token = self.current_session.provider_token
self._save_session(session)
return session |
Ok thank you! Is it correct that the effect is the same in two snippets below?? supabase_client = create_client(url, anon_key)
supabase_client.set_auth(user_jwt_key) supabase_client = create_client(url, user_jwt_key) |
If I'm not mistaken (because I'm familiar with By the way, what you want to make in the 1st option is currently possible. Although I do not know if a new release has been published with that change. supabase_client = create_client(url, anon_key)
supabase_client.auth.set_auth(user_jwt_key) |
Hey, not sure if I'm doing anything wrong. But the following does not seem to work. session = supabase.auth.sign_in(email=os.environ.get("EMAIL"), password=os.environ.get("PASS"))
supabase.auth.set_auth(access_token=session.access_token)
data = supabase.table("videos").select("*").execute()
print(len(data.data)) This prints 0 normally but if I create the supabase client with the secret key, it prints the total number of rows. The table has RLS enabled. |
from supabase import create_client, Client |
Is your feature request related to a problem? Please describe.
I would like to have this feature:
supabase.auth.setAuth(jwt);
supabase/supabase#1094 (reply in thread)
Currently I think I can just use JWT in
create_client(url, key)
and effect will be the same? (I'm not sure)Describe the solution you'd like
above
Describe alternatives you've considered
n/a
Additional context
n/a
The text was updated successfully, but these errors were encountered: