31 lines
916 B
Dart
31 lines
916 B
Dart
|
import 'package:http/browser_client.dart';
|
||
|
import "package:http/http.dart";
|
||
|
|
||
|
BaseClient getCookieClient() => ClientWithCookies();
|
||
|
|
||
|
class ClientWithCookies extends BrowserClient {
|
||
|
String _accessToken = "asdasdasd";
|
||
|
String _refreshToken;
|
||
|
|
||
|
@override
|
||
|
Future<StreamedResponse> send(BaseRequest request) async {
|
||
|
request.headers.addAll({
|
||
|
'X-Imagini-AccessToken': _accessToken,
|
||
|
'X-Imagini-RefreshToken': _refreshToken,
|
||
|
});
|
||
|
|
||
|
return super.send(request).then((response) {
|
||
|
if (response.headers.containsKey("x-imagini-accesstoken")) {
|
||
|
this._accessToken = response.headers["x-imagini-accesstoken"];
|
||
|
}
|
||
|
if (response.headers.containsKey("x-imagini-refreshtoken")) {
|
||
|
this._refreshToken = response.headers["x-imagini-refreshtoken"];
|
||
|
}
|
||
|
|
||
|
print("Access Token: $_accessToken");
|
||
|
print("Refresh Token: $_refreshToken");
|
||
|
return response;
|
||
|
});
|
||
|
}
|
||
|
}
|