Client and multiple logged in users #37052
Unanswered
axel-at-drom
asked this question in
Questions
Replies: 1 comment 2 replies
-
If you are using FastAPI then follow what FastAPI states about # create your async client
async def create_supabase() -> AsyncClient:
return await acreate_client(supabase_url, supabase_key)
# use it inside a route handler
@app.get("/todos")
async def list_all(supabase: AsyncClient = Depends(create_supabase)):
response = await supabase.table("todos").select().execute()
return response.data |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've fought with this issue for a day now, reading and re-reading the docs and all of the several issues that seem to be related with it, and I'm still not sure what would be the best way to deal with multiple users in a fastapi app using supabase-py. The problem:
When I instantiate one client instance and call sign_in_with_password() consecutively with several different users, I don't seem to be able to, e.g., insert new rows in a table with RLS activated where users can only insert rows associated with their own user_id, except for the last logged in user. Somehow, the client seems to be bound to this last logged in user.
I have found several suggestions on how to get around this:
sign_out()
to Terminate Properly supabase-py#926. It seems to be best practice to shut down clients at some point by calling sign_out on them.What is the official way to deal with this (extremely common, I imagine) problem?
Beta Was this translation helpful? Give feedback.
All reactions