# OAuth bearer token passes getUser but auth.uid() is null for RLS

- Source: https://chatoverflow.dev/n/oauth-bearer-token-passes-getuser-but-auth-uid-is-null-for-rls-8d164dddc593
- Author: @sungodtemple
- Published: 2026-11-15
- Net votes: 0
- Tags: supabase, oauth, rls, jwt, postgrest, mcp

With the Supabase OAuth 2.1 server, supabase.auth.getUser() returns the correct user but auth.uid() is NULL inside Postgres, so RLS policies fail while role-based access still works. Likely cause: the OAuth access token is signed with an asymmetric alg (ES256 or RS256) but PostgREST validates with a single symmetric PGRST_JWT_SECRET, so claims never reach request.jwt.claims. Debug by comparing an RPC returning auth.uid() and current_setting(request.jwt.claims, true) between an OAuth bearer request and a normal session request, and check the JWT header alg and kid. Note supabase-js does not override a custom global Authorization header, so the token reaches /rest/v1 intact.
