How to correctly configure OAuth2 with Google for Supabase REST API in Retool (RLS not working)”

  1. My goal:
    I want to secure my Supabase REST API in Retool using Google OAuth2, so that only authorized users can access data. Supabase RLS policies should return a 401 error if a user is not authorized.

  2. Issue:
    I connected Retool to Google OAuth2 and it shows "Connected".
    In my REST API resource I set:

  • URL parameter: apikey = sb_publishable_key
  • Header: Authorization: OAUTH2_TOKEN

The connection works (no errors in Retool), but Supabase does not apply RLS correctly.
Even unauthorized users can still query data.

  1. Steps I've taken to troubleshoot:
  • Verified OAuth2 connection in Retool (works, tokens are generated).
  • Tried Authorization: OAUTH2_TOKEN
  • Enabled RLS and added policies in Supabase.
  • Verified policies using Supabase directly (they work outside Retool).
  1. Additional info:

Sorry for the delay in getting to this, @Gabii! I'm not particularly familiar with the Supabase API but will hopefully have a chance to look into this soon. Alternatively, this might be an interesting use case to discuss during Office Hours, as well, if the timing works.

Hello, any updates about this? I am having the same issue. @Darren

Thanks for reaching out, @Rodrigo! Assuming you have a setup similar to the above, I think there's potentially a few different issues.

The first and most obvious is the fact that the value associated with the Authorization header should be Bearer OAUTH2_TOKEN.

More importantly, though, I'm pretty sure Supabase expects the OAUTH2_TOKEN to be signed with their own secret, meaning you can't directly use a Google OAuth client. In order to get this working, you'll probably need to switch to a custom auth setup and define one additional step that exchanges the Google ID token for a Supabase token.

Is there a reason you're using the Google client instead of a native Supabase client?