buildAuthenticatedDio function

Dio buildAuthenticatedDio({
  1. required BaseOptions baseOptions,
  2. required NullParamsInterceptor nullParamsInterceptor,
  3. required Fresh<AuthTokenModel> fresh,
  4. required AppExceptionMappingInterceptor exceptionMappingInterceptor,
  5. required AuthFailureInterceptor authFailureInterceptor,
  6. required ReportingInterceptor reportingInterceptor,
  7. required PrettyDioLogger prettyDioLogger,
  8. List<String> allowedSHA256Fingerprints = SecurityConstants.allowedSHA256Fingerprints,
})

Builds the authenticated Dio client, for protected routes.

Interceptor order: null-param removal → fresh (token attach + refresh) → exception mapping → auth-revocation detection → retry → reporting → pretty logging (always last).

Implementation

Dio buildAuthenticatedDio({
  required BaseOptions baseOptions,
  required NullParamsInterceptor nullParamsInterceptor,
  required Fresh<AuthTokenModel> fresh,
  required AppExceptionMappingInterceptor exceptionMappingInterceptor,
  required AuthFailureInterceptor authFailureInterceptor,
  required ReportingInterceptor reportingInterceptor,
  required PrettyDioLogger prettyDioLogger,
  List<String> allowedSHA256Fingerprints = SecurityConstants.allowedSHA256Fingerprints,
}) {
  return _buildDio(
    baseOptions: baseOptions,
    allowedSHA256Fingerprints: allowedSHA256Fingerprints,
    interceptors: (Dio dio) => <Interceptor>[
      nullParamsInterceptor,
      fresh,
      exceptionMappingInterceptor,
      authFailureInterceptor,
      _buildRetryInterceptor(dio),
      reportingInterceptor,
      prettyDioLogger,
    ],
  );
}