supabase-community / supabase-kt

A Kotlin Multiplatform Client for Supabase.
https://supabase.com/docs/reference/kotlin/introduction
MIT License
421 stars 38 forks source link

[Question]: Unable to access public schema. Permission denied #720

Closed sivansundar closed 2 months ago

sivansundar commented 2 months ago

General info

What is your question?

So I try to access a public table on my database and I get an exception saying "permission denied".

My android app has Supabase Auth integrated and is using the right token.

Tried the following with RLS settings :

  1. Enabling RLS and gave access for authenticated users
  2. Enabling RLS and gave access for all users
  3. Disabled RLS completely.

Yet I get an exception saying "permission denied".

Relevant log output (optional)

io.github.jan.supabase.exceptions.UnknownRestException: permission denied for schema public
                                                                                                    URL: https://XXX.supabase.co/rest/v1/<TABLE_NAME>?columns=id%2Cuser_id%2Ctitle%2Cvendor_name%2Camount%2Ccurrency%2Ccategory%2Cnotes&select=%2A
                                                                                                    Headers: [Authorization=[Bearer "access token"], Prefer=[return=representation], Content-Profile=[public], apikey=["apiKey"], X-Client-Info=[supabase-kt/2.6.1], Accept=[application/json], Accept-Charset=[UTF-8]]

Http Method: POST at io.github.jan.supabase.postgrest.PostgrestImpl.parseErrorResponse(PostgrestImpl.kt:50)
                                                                                               at io.github.jan.supabase.gotrue.AuthenticatedSupabaseApiKt$authenticatedSupabaseApi$3.invoke(AuthenticatedSupabaseApi.kt:60)
                                                                                               at io.github.jan.supabase.gotrue.AuthenticatedSupabaseApiKt$authenticatedSupabaseApi$3.invoke(AuthenticatedSupabaseApi.kt:60)
                                                                                               at io.github.jan.supabase.network.SupabaseApi.rawRequest$suspendImpl(SupabaseApi.kt:25)
                                                                                               at io.github.jan.supabase.network.SupabaseApi$rawRequest$1.invokeSuspend(Unknown Source:15)
                                                                                                at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
                                                                                                at kotlinx.coroutines.EventLoop.processUnconfinedEvent(EventLoop.common.kt:65)
                                                                                                at kotlinx.coroutines.internal.DispatchedContinuation.resumeWith(DispatchedContinuation.kt:327)
                                                                                                at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:146)
                                                                                                at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:120)
                                                                                                at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:11)
                                                                                                at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:70)
                                                                                                 at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
                                                                                                 at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
                                                                                                 at android.os.Handler.handleCallback(Handler.java:959)
                                                                                                 at android.os.Handler.dispatchMessage(Handler.java:100)
                                                                                                 at android.os.Looper.loopOnce(Looper.java:232)
                                                                                                 at android.os.Looper.loop(Looper.java:317)
                                                                                                 at android.app.ActivityThread.main(ActivityThread.java:8623)
                                                                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                                                                 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
                                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:894)
                                                                                                 Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [io.sellmair.evas.EventsImpl@751458f, io.sellmair.evas.StatesImpl@c66601c, StandaloneCoroutine{Cancelling}@a87a425, Dispatchers.Main.immediate]
jan-tennert commented 2 months ago

Did you take a look at https://stackoverflow.com/questions/67551593/supabase-client-permission-denied-for-schema-public?

sivansundar commented 2 months ago

Thanks! This worked. Wasnt aware that a grant was required.

jan-tennert commented 2 months ago

Well you shouldn't have this problem in the first place, but glad that it worked!

sivansundar commented 2 months ago

Curious though. Created a db off the dashboard with tables and this popped up. Not sure if this isnt set by default.