import 'package:grpc/grpc.dart'; import 'generated/smm_core.pbgrpc.dart'; class AuthenticationInterceptor extends ClientInterceptor { Future _provider(Map metadata, String uri) async { metadata['Authorization'] = "Y3JhYjpjcmFi"; } @override ResponseFuture interceptUnary( ClientMethod method, Q request, CallOptions options, invoker) { return super.interceptUnary(method, request, options.mergedWith(CallOptions(providers: [_provider])), invoker); } } class SmmCoreTerminalClient { late final ClientChannel channel; late final SmmCoreClient stub; SmmCoreTerminalClient() { channel = ClientChannel( '0.0.0.0', port: 8080, options: ChannelOptions(credentials: ChannelCredentials.insecure()), ); stub = SmmCoreClient(channel, interceptors: [AuthenticationInterceptor()]); } }