supabase-community / auth-py

Python client implementation for Supabase Auth
MIT License
61 stars 33 forks source link

When creating a client from tokens purely there's an issue #537

Open mathatan opened 2 weeks ago

mathatan commented 2 weeks ago

Bug report

Describe the bug

Trying to create a client with create_async_client results in TypeError: object NoneType can't be used in 'await' expression errors if the session is not defined before get_session is called with tokens. (or in any case when data is set to None before trying to retrieve it)

To Reproduce

Initialize session with (or similar):

self.supabase_client = await create_async_client(
    settings.SUPABASE_URL,
    settings.SUPABASE_KEY,
    options=ClientOptions(
        headers={"Authorization": f"Bearer {self.access_token}"},
        postgrest_client_timeout=10,
        storage_client_timeout=10,
    ),
)

await self.supabase_client.auth.set_session(access_token=self.access_token,  refresh_token=self.refresh_token)

Then later call (against the client instance initialized in code above):

session = await supabase_client.auth.get_session()

Expected behavior

No thrown errors

System information

Additional context

PR with a fix: https://github.com/supabase-community/auth-py/pull/536

silentworks commented 1 week ago

In your example above you are showing you instantiating the client inside a class and then the later call is showing you calling supabase directly. I have no idea where this supabase is coming from. I can't see any bugs here. Please provide a reproducible example repository.