dpop_flutter_http 0.1.1
dpop_flutter_http: ^0.1.1 copied to clipboard
package:http integration for dpop_flutter - a thin DpopHttpClient wrapper that attaches DPoP Authorization/DPoP headers to every request.
import 'package:dpop_flutter/dpop_flutter.dart';
import 'package:dpop_flutter_http/dpop_flutter_http.dart';
/// A stub standing in for your app's real token storage/refresh logic.
class _StaticTokenProvider implements AccessTokenProvider {
const _StaticTokenProvider(this._token);
final String _token;
@override
Future<String?> getAccessToken() async => _token;
}
/// Demonstrates [DpopHttpClient]: a `package:http`-compatible client that
/// attaches DPoP headers to every request automatically.
Future<void> main() async {
final dpop = DpopClient(keyStore: SecureDpopKeyStore());
await dpop.initialize();
final client = DpopHttpClient(
dpop: dpop,
tokenProvider:
const _StaticTokenProvider('replace-with-a-real-access-token'),
);
final response =
await client.get(Uri.parse('https://api.example.com/profile'));
// ignore: avoid_print
print('${response.statusCode}: ${response.body}');
}