dpop_flutter_http 0.1.1 copy "dpop_flutter_http: ^0.1.1" to clipboard
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.

example/main.dart

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}');
}
1
likes
160
points
32
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

package:http integration for dpop_flutter - a thin DpopHttpClient wrapper that attaches DPoP Authorization/DPoP headers to every request.

Repository (GitHub)
View/report issues
Contributing

Topics

#dpop #oauth #http

License

MIT (license)

Dependencies

dpop_flutter, flutter, http

More

Packages that depend on dpop_flutter_http