interceptUnary<Q, R> method
ResponseFuture<R>
interceptUnary<Q, R>(
- ClientMethod<
Q, R> method, - Q request,
- CallOptions options,
- ClientUnaryInvoker<
Q, R> invoker,
Adds the access token to the gRPC call's metadata if the token is present.
Implementation
@override
ResponseFuture<R> interceptUnary<Q, R>(
ClientMethod<Q, R> method,
Q request,
CallOptions options,
ClientUnaryInvoker<Q, R> invoker,
) {
Future<void> addAccessToken(Map<String, String> metadata, String _) async {
final token = await _getAccessToken();
if (token != null) {
metadata['access_token'] = token;
}
}
return invoker(
method,
request,
options.mergedWith(CallOptions(providers: [addAccessToken])),
);
}