Replies: 5 comments 3 replies
-
This is a client -> server .NET -> Supabase request flow, correct? And the requests are stateless? You can't refresh or populate a session without a refresh token. So, provided you have the refresh token, you should be able to do it by a combination of the following: supabaseClient.Auth.SetAuth(token);
await supabaseClient.Auth.RefreshToken(refreshToken); Which will refresh the session and set the state in the gotrue client. |
Beta Was this translation helpful? Give feedback.
-
Thanks but I don't see this method available, I'm currently using the nuget package 0.12.2. Is there any extra dependency I should add to access this? A followup question I believe would be, this seems like it would render my current access token unusable? Since this is an API, i can't have a client application be constantly refreshing its tokens Are stateless APIs out of the scope of how Supabase Auth works? |
Beta Was this translation helpful? Give feedback.
-
Check out https://github.com/supabase-community/gotrue-csharp/blob/master/Gotrue/StatelessClient.cs - that's the one you want. |
Beta Was this translation helpful? Give feedback.
-
I was re-reading the API docs in the supabase docs:
It makes me wonder why calling the SetAuth (which makes overwrites the JWT used in the Authorization header) is not allowing my supabase default's value as On top of that, why is my insert policy blocking my request saying that my "Only allow authenticated users to insert values" is being violated ? Shouldn't the Authorization Header sent to supabase allow me to insert since the user should be detected as authenticated? For completion, here's my RLS insert policy: |
Beta Was this translation helpful? Give feedback.
-
Understood! I'm still a bit unsure on why all the session would need to be parsed on the csharp client if the Authorization header should suffice (of course, not against having the session available 😛 ) |
Beta Was this translation helpful? Give feedback.
-
Hi all.
I am building an API which is using supabase auth among other things.
I have been able to successfully implement sign up and sign in options via email provider.
I am using the access_token generated by my signIn method as my Authorization: Bearer token. The token is being parsed nicely and my aspnet core endpoints are correctly using the token for authorization on endpoints.
However, I am trying to introduce RLS in my tables, I expect to not need to pass in a value to my user_id column, which is a foreign key to the auth.users table.
I expect to automatically insert the value to this column via the signed In user. Right now, the default value of the column is set to auth().uid (which works perfectly fine on another project I have in nodejs).
I figured that the session is not being picked up by my netcore application, so I created a middleware:
However, this is just setting the Auth header for the client (correctly), but SupabaseClient.Auth.Session is still null, which I think is causing my user_id column to not be populated.
As you can see, I also tried calling .Auth.RetrieveSessionAsync(); after setting the Auth header, but still not working.
I would really like to have this user_id column be automatically picked up from the current session when creating records.
Am I missing something? Is this something possible to be done on the csharp client? In the nodejs application, I could do this by calling supabase.auth.setSession(accessToken, refreshToken) but that doesn't seem to be an option in the c# client.
Beta Was this translation helpful? Give feedback.
All reactions