-
-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use custom Jwt in realtime client out of the box #442
Comments
Hi @squallsama , Try this : 1 - Change your JWT Token claims with role, aud, and sub. 2 - To use your own JWT with Realtime make sure to set the token after instantiating the Supabase client and before connecting to a Channel.
See : https://github.com/orgs/supabase/discussions/13620#discussioncomment-5599317 https://supabase.com/docs/guides/realtime/postgres-changes#custom-tokens hope it helps |
My token contains exactly these fields with exactly same values that you are mentioned. |
And did you add these two lines before the call to the strem() method?
|
Describe the bug
I have flutter application and I'm using custom signed Jwt token:
await Supabase.initialize( url: Env.supabaseUrl, anonKey: Env.supabaseAnonKey, headers: { 'Authorization': 'Bearer $userCustomJwt', });
Everything fine except realtime. It doesn't work without switching auth via:
Supabase.instance.client.realtime.setAuth(userCustomJwt);
After that realtime start working fine.I saw doc about it https://supabase.com/docs/guides/realtime/extensions/postgres-changes#custom-tokens and also there is similar issue, but related to js https://github.com/orgs/supabase/discussions/13620 and js library allows user to create Supabase client with custom Realtime headers.
To Reproduce
Steps to reproduce the behavior:
await Supabase.initialize(
url: Env.supabaseUrl,
anonKey: Env.supabaseAnonKey,
headers: {
'Authorization': 'Bearer $userCustomJwt',
});
client .from('test_table') .stream(primaryKey: ['id']) .order('created_at') .map((maps) => maps.map((map) { return TestMessage.fromMap(map: map); }).toList())
Supabase.instance.client.realtime.setAuth(userCustomJwt);
Expected behavior
Supabase initialized with custom token and this custom jwt token used for all clients and for realtime client too
The text was updated successfully, but these errors were encountered: