realtime-py icon indicating copy to clipboard operation
realtime-py copied to clipboard

ANON-KEY not working on change notification

Open qishansun opened this issue 2 years ago • 1 comments

Bug report

Describe the bug

Follow demo step, as

from realtime.connection import Socket

SUPABASE_ID = "dlzlllxhaakqdmaapvji"
API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MT"

def callback1(payload):
    print("Callback 1: ", payload)

if __name__ == "__main__":
    URL = f"wss://{SUPABASE_ID}.supabase.co/realtime/v1/websocket?apikey={API_KEY}&vsn=1.0.0"
    s = Socket(URL)
    s.connect()

    channel_1 = s.set_channel("realtime:*")
    channel_1.join().on("UPDATE", callback1)
    s.listen()

When API_KEY refers to Supabase secret service key, it works as expected. But when API_KEY refers to ANON Key, it does not work at all -- code runs without compliant but cannot receive notification when change happened in table , even with access authorized by RLS on table.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. use demo code.
  2. toggle API_KEY between ANON_KEY and SERVICE_KEY.
  3. then change something in supabase table.
  4. check difference.

Expected behavior

ANON-KEY , or with authenticated role should receive change notification as SERVICE_KEY.

Hope the document make it clear on authorization method used in this client, and also how RLS could be integrated.

qishansun avatar May 01 '23 10:05 qishansun

I faced the same problem with the anon key for real-time data listen. Still, they haven't fixed that problem.

FayzulSaimun avatar Dec 02 '23 13:12 FayzulSaimun