dio_http_interceptor.dart 575 B

12345678910111213141516
  1. import 'package:dio/dio.dart';
  2. import 'package:hive_flutter/hive_flutter.dart';
  3. import 'package:immich_mobile/constants/hive_box.dart';
  4. class AuthenticatedRequestInterceptor extends Interceptor {
  5. @override
  6. void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
  7. // debugPrint('REQUEST[${options.method}] => PATH: ${options.path}');
  8. var box = Hive.box(userInfoBox);
  9. options.headers["Authorization"] = "Bearer ${box.get(accessTokenKey)}";
  10. options.responseType = ResponseType.plain;
  11. return super.onRequest(options, handler);
  12. }
  13. }