File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -365,9 +365,23 @@ public final class RealtimeClientV2: Sendable {
365365 }
366366
367367 /// Sets the JWT access token used for channel subscription authorization and Realtime RLS.
368- /// - Parameter token: A JWT string.
369- public func setAuth( _ token: String ? ) async {
370- mutableState. withValue {
368+ ///
369+ /// If `token` is nil it will use the ``RealtimeClientOptions/accessToken`` callback function or the token set on the client.
370+ ///
371+ /// On callback used, it will set the value of the token internal to the client.
372+ /// - Parameter token: A JWT string to override the token set on the client.
373+ public func setAuth( _ token: String ? = nil ) async {
374+ var token = token
375+
376+ if token == nil {
377+ token = try ? await options. accessToken ? ( )
378+ }
379+
380+ if token == nil {
381+ token = mutableState. accessToken
382+ }
383+
384+ mutableState. withValue { [ token] in
371385 $0. accessToken = token
372386 }
373387
You can’t perform that action at this time.
0 commit comments