File tree Expand file tree Collapse file tree 4 files changed +10
-2
lines changed Expand file tree Collapse file tree 4 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,8 @@ class RealtimeClient {
104
104
eventsPerSecondLimitMs = (1000 / int .parse (eventsPerSecond)).floor ();
105
105
}
106
106
107
- accessToken = this .headers['Authorization' ]? .split (' ' ).last;
107
+ final customJWT = this .headers['Authorization' ]? .split (' ' ).last;
108
+ accessToken = customJWT ?? params['apikey' ];
108
109
109
110
this .reconnectAfterMs =
110
111
reconnectAfterMs ?? RetryTimer .createRetryFunction ();
Original file line number Diff line number Diff line change @@ -39,7 +39,8 @@ void main() {
39
39
40
40
group ('constructor' , () {
41
41
test ('sets defaults' , () async {
42
- final socket = RealtimeClient ('wss://example.com/socket' );
42
+ final socket =
43
+ RealtimeClient ('wss://example.com/socket' , params: {'apikey' : '123' });
43
44
expect (socket.channels.length, 0 );
44
45
expect (socket.sendBuffer.length, 0 );
45
46
expect (socket.ref, 0 );
@@ -65,6 +66,7 @@ void main() {
65
66
socket.headers['X-Client-Info' ]! .split ('/' ).first,
66
67
'realtime-dart' ,
67
68
);
69
+ expect (socket.accessToken, '123' );
68
70
});
69
71
70
72
test ('overrides some defaults with options' , () async {
Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ void main() {
55
55
containsPair ('log_level' , 'info' ),
56
56
);
57
57
});
58
+
59
+ test ('realtime access token is set properly' , () {
60
+ expect (client.realtime.accessToken, supabaseKey);
61
+ });
58
62
});
59
63
60
64
group ('auth' , () {
Original file line number Diff line number Diff line change @@ -159,6 +159,7 @@ class SupabaseAuth with WidgetsBindingObserver {
159
159
160
160
@override
161
161
void didChangeAppLifecycleState (AppLifecycleState state) {
162
+ // ignore:missing_enum_constant_in_switch
162
163
switch (state) {
163
164
case AppLifecycleState .resumed:
164
165
_recoverSupabaseSession ();
You can’t perform that action at this time.
0 commit comments