supabase-community / supabase-csharp

A C# Client library for Supabase
https://github.com/supabase-community/supabase-csharp/wiki
MIT License
499 stars 50 forks source link

Unable to persist session using blazor wasm #118

Closed maxtsw closed 1 year ago

maxtsw commented 1 year ago

I have been looking through and I can't seem to find any information, I followed the blazor example, and keep getting errors when trying to retrieve the session, I also don't see at any point when the load session code is run, you have RetrieveSessionAsync, however this doesn't from what I can see, this doesn't call the session handler, if the user logs in then it seems to work, however if they close the browser this does not work, and I have debugged the code and at no point does the SessionHandler.LoadSession() get run.

acupofjose commented 1 year ago

Can you take a look here and see if it answers?

https://github.com/acupofjose/supasharp-todo/blob/master/SupasharpTodo.Shared/Providers/SupabaseAuthenticationStateProvider.cs

wiverson commented 1 year ago

Not sure about Blazor, but in the Unity template the session is loaded once as part of the client initialization, and then the persistence session handler is called later to save it. Idea being that the session is loaded once off disk when the app launches but otherwise the client is running and the session is in memory, persisted on occasion depending on events.

https://github.com/wiverson/supabase-unity-template/blob/0894da86cbcb73fe7c7f0dd6e7a1793fa26f98cb/Assets/App/com/example/SupabaseManager.cs#L27

maxtsw commented 1 year ago

That looks to be working thank you for your help and quick reply