forPrivateChannel static method

EndpointAuthorizableChannelTokenAuthorizationDelegate<PrivateChannelAuthorizationData> forPrivateChannel({
  1. required Uri authorizationEndpoint,
  2. required Map<String, String> headers,
  3. bool overrideContentTypeHeader = true,
  4. EndpointAuthorizableChannelTokenAuthorizationParser<PrivateChannelAuthorizationData> parser = _defaultParserForPrivateChannel,
  5. EndpointAuthFailedCallback? onAuthFailed,
})

Providing an instance of this class to authorize to PrivateChannels with PrivateChannelAuthorizationData.

Set overrideContentTypeHeader to false in order to prevent 'content-type': 'application/x-www-form-urlencoded' from being added into provided headers.

If the custom parser is not provided the default one will be used:

 static PrivateChannelAuthorizationData _defaultParserForPrivateChannel(
  http.Response response,
 ) {
  final decoded = jsonDecode(response.body) as Map;
  final auth = decoded['auth'] as String;
  return PrivateChannelAuthorizationData(
    authKey: auth,
  );
}

Implementation

///   return PrivateChannelAuthorizationData(
///     authKey: auth,
///   );
/// }
/// ```
static EndpointAuthorizableChannelTokenAuthorizationDelegate<
    PrivateChannelAuthorizationData> forPrivateChannel({
  required Uri authorizationEndpoint,
  required Map<String, String> headers,
  bool overrideContentTypeHeader = true,
  EndpointAuthorizableChannelTokenAuthorizationParser<
          PrivateChannelAuthorizationData>
      parser = _defaultParserForPrivateChannel,
  EndpointAuthFailedCallback? onAuthFailed,
}) =>
    EndpointAuthorizableChannelTokenAuthorizationDelegate._(
      overrideContentTypeHeader: overrideContentTypeHeader,
      authorizationEndpoint: authorizationEndpoint,
      onAuthFailed: onAuthFailed,
      headers: headers,
      parser: parser,
    );