1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-21 01:39:59 +02:00
immich/mobile/lib/utils/dio_http_interceptor.dart

18 lines
615 B
Dart
Raw Normal View History

2022-02-03 18:06:44 +02:00
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:immich_mobile/constants/hive_box.dart';
class AuthenticatedRequestInterceptor extends Interceptor {
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
// debugPrint('REQUEST[${options.method}] => PATH: ${options.path}');
var box = Hive.box(userInfoBox);
options.headers["Authorization"] = "Bearer ${box.get(accessTokenKey)}";
options.responseType = ResponseType.plain;
return super.onRequest(options, handler);
}
}