Just looking at this again, and it is quite straightforward of course:

public override AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall
<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, 
TResponse> context, AsyncServerStreamingCallContinuation<TRequest, TResponse
> continuation)
{
    context.Options.Headers.Add(CreateBearerTokenHeader("..."));
    return continuation(request, context);
}

Just need to figure out how to catch a 401 response, refresh the token and 
retry.... 

I've seen this one 
<https://github.com/grpc/grpc/issues/15623#issuecomment-398487843>, but it 
would be great to have a few more examples of interceptor usage, 
particularly with streaming responses. Does anybody know of something?


On Thursday, 6 December 2018 11:02:26 UTC+1, Mark Nuttall-Smith wrote:
>
> Hi,
>
> I'd like to use a C# interceptor to transparently refresh an access token, 
> similar to the System.Net.Http.DelegatingHandler here: 
> https://github.com/IdentityModel/IdentityModel.OidcClient2/blob/v3/src/RefreshTokenDelegatingHandler.cs
>
> My question is: is it possible to set a header in the call metadata using 
> the server streaming call interceptor?
>
> I also see the metadata interceptor, but this doesn't have the 
> continuation, so I can't try and retry if I get a 401 unauthorized.
>
> public static CallInvoker Intercept(this CallInvoker invoker, Func<Metadata, 
> Metadata> interceptor)
>
>
> TIA,
> Mark
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/5b25f93c-e1a4-4727-abaa-ab05b4dff4fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to