File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 1+ import 'package:http/http.dart' as http;
12import 'dart:async' show StreamSubscription;
23import 'dart:io' ;
34import 'dart:convert' ;
@@ -22,6 +23,18 @@ ColorScheme colorSchemeFromContext(BuildContext context) {
2223 }
2324}
2425
26+ class MyHTTPClient extends http.BaseClient {
27+ final http.Client _inner;
28+
29+ MyHTTPClient (this ._inner);
30+
31+ @override
32+ Future <http.StreamedResponse > send (http.BaseRequest request) {
33+ request.headers["x-custom-header" ] = "42" ;
34+ return _inner.send (request);
35+ }
36+ }
37+
2538void main () {
2639 if (Platform .isIOS) {
2740 wechatRedirectURI =
@@ -917,6 +930,7 @@ class _MyAppState extends State<MyApp> {
917930 ),
918931 )
919932 : null ,
933+ httpClient: MyHTTPClient (http.Client ()),
920934 );
921935 _sub? .cancel ();
922936 await authgear.configure ();
Original file line number Diff line number Diff line change @@ -280,6 +280,7 @@ class Authgear implements AuthgearHttpClientDelegate {
280280 this .preAuthenticatedURLEnabled = false ,
281281 TokenStorage ? tokenStorage,
282282 UIImplementation ? uiImplementation,
283+ Client ? httpClient,
283284 }) : _tokenStorage = tokenStorage ?? PersistentTokenStorage (),
284285 _uiImplementation = uiImplementation ?? DeviceBrowserUIImplementation (),
285286 _storage = PersistentContainerStorage (),
@@ -288,7 +289,7 @@ class Authgear implements AuthgearHttpClientDelegate {
288289 namespace: name,
289290 sharedStorage: _sharedStorage,
290291 );
291- final plainHttpClient = Client ();
292+ final plainHttpClient = httpClient ?? Client ();
292293 final authgearHttpClient = AuthgearHttpClient (this , plainHttpClient);
293294 _apiClient = APIClient (
294295 endpoint: endpoint,
You can’t perform that action at this time.
0 commit comments