forPrivateEncryptedChannel static method

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

Providing an instance of this class to authorize to PrivateEncryptedChannels with PrivateEncryptedChannelAuthorizationData.

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 PrivateEncryptedChannelAuthorizationData
    _defaultParserForPrivateEncryptedChannel(http.Response response) {
  final decoded = jsonDecode(response.body) as Map;
  final auth = decoded['auth'] as String;
  final sharedSecret = decoded['shared_secret'] as String;
  final key = base64Decode(sharedSecret);
  return PrivateEncryptedChannelAuthorizationData(
    authKey: auth,
    sharedSecret: key,
  );
}

Implementation

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