Replies: 5 comments 4 replies
-
Yep! You don’t have to use the postgrest-csharp or realtime-csharp client functionality from the main supabase-csharp repo. You would just use the main client and access the Gotrue Auth from |
Beta Was this translation helpful? Give feedback.
-
Just to clarify, its my Web Api that is returning the 401, not supabase. SWAGGER <--> MYAPI <--> SUPABASE. When I debug my code, the pointer does not step into the endpoint. It just returns the 401, so the 401 is not coming from supabase. The token was generated about 30 seconds before the call to the auth endpoint so it cant have expired. It last 360 seconds as far as I can see. Swagger doesnt malform its headers but I double checked by using a different client - Postman. There are 3 RLS policies. Everyone can view. User can Update and Insert. Should I take a different approach and have no auth on the web api endpoint and pass through the call to supabase platform and let the auth be done there? That seems shoddy to me. Very confusing. There are loads of examples for JS stuff but nothing for .Net. Need Milan Jovanovic to put together a tutorial using a .net web api with auth :-) |
Beta Was this translation helpful? Give feedback.
-
I removed the RequireAuthentication from my api and let the call go through to supabase ( using swagger with the access token added). It failed RLS. No idea why. Postgrest.Exceptions.PostgrestException: {"code":"42501","details":null,"hint":null,"message":"new row violates row-level security policy for table \"profiles\""}
at Postgrest.Helpers.MakeRequest(ClientOptions clientOptions, HttpMethod method, String url, JsonSerializerSettings serializerSettings, Object data, Dictionary`2 headers, CancellationToken cancellationToken)
at Postgrest.Helpers.MakeRequest[T](ClientOptions clientOptions, HttpMethod method, String url, JsonSerializerSettings serializerSettings, Object data, Dictionary`2 headers, Func`1 getHeaders, CancellationToken cancellationToken)
at Program.<>c.<<<Main>$>b__0_6>d.MoveNext() in /home/greg/Dev/Projects/FSBO/src/FSBO.Api/Program.cs:line 113
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Http.RequestDelegateFactory.<>c__DisplayClass102_2.<<HandleRequestBodyAndCompileRequestDelegateForJson>b__2>d.MoveNext()
--- End of stack trace from previous location ---
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context) HEADERSAccept: / |
Beta Was this translation helpful? Give feedback.
-
How can you see that the token is valid?
|
Beta Was this translation helpful? Give feedback.
-
Got it working. Turns out I had set foreign key of the auth.user table as the primary key of the profiles table. Which its not, its a reference column. Duh. But the my API is still throwing a 401 Thanks for the help. |
Beta Was this translation helpful? Give feedback.
-
I am using EF Core with Supabase , but working directly with the Postgres database (using the postgres db connection string in app settings). Migrations works fine and all is good, but now I want to take advantage of the Auth stuff and that means using the csharp client. But, as I am in project development, I still want to use EF Core to generate table structures as my models evolve. Is this possible? Use EF Core and csharp client?
Beta Was this translation helpful? Give feedback.
All reactions