Class OAuth2Interceptor<T>
- Namespace
- Arc4u.gRPC.Interceptors
- Assembly
- Arc4u.gRPC.dll
Inject in the Metadata's message the Bearer token of the authenticated user.
public class OAuth2Interceptor<T> : Interceptor
Type Parameters
TThe category type of the logger.
- Inheritance
-
OAuth2Interceptor<T>
- Inherited Members
Constructors
OAuth2Interceptor(IServiceProvider, ILogger<T>, IKeyValueSettings)
This is the constructor to use in a Client scenario like a Wpf or a MAUI or a console. The IApplicationContext and the ITokenProvider are not scoped to an httpRequest or a job, etc...
public OAuth2Interceptor(IServiceProvider serviceProvider, ILogger<T> logger, IKeyValueSettings keyValuesSettings)
Parameters
serviceProviderIServiceProviderloggerILogger<T>keyValuesSettingsIKeyValueSettingsProperty bag for the token povider.
Exceptions
OAuth2Interceptor(IServiceProvider, ILogger<T>, string)
Initializes a new instance of the OAuth2Interceptor<T> class with the settings registered by name.
public OAuth2Interceptor(IServiceProvider serviceProvider, ILogger<T> logger, string resolvingName)
Parameters
serviceProviderIServiceProviderIServiceProvider, also used to resolve the settings.
loggerILogger<T>resolvingNamestringThe name of the SimpleKeyValueSettings options holding the property bag for the token provider.
Exceptions
- ArgumentNullException
serviceProvideris null.- ConfigurationException
No settings exist with that name.
Methods
AsyncClientStreamingCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse>, AsyncClientStreamingCallContinuation<TRequest, TResponse>)
Intercepts an asynchronous invocation of a client streaming call.
public override AsyncClientStreamingCall<TRequest, TResponse> AsyncClientStreamingCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> context, Interceptor.AsyncClientStreamingCallContinuation<TRequest, TResponse> continuation) where TRequest : class where TResponse : class
Parameters
contextClientInterceptorContext<TRequest, TResponse>The ClientInterceptorContext<TRequest, TResponse> associated with the current invocation.
continuationInterceptor.AsyncClientStreamingCallContinuation<TRequest, TResponse>The callback that continues the invocation process. This can be invoked zero or more times by the interceptor. The interceptor can invoke the continuation passing the given context argument, or substitute as it sees fit.
Returns
- AsyncClientStreamingCall<TRequest, TResponse>
An instance of AsyncClientStreamingCall<TRequest, TResponse> representing an asynchronous client-streaming invocation. The interceptor can simply return the return value of the continuation delegate passed to it intact, or construct its own substitute as it sees fit.
Type Parameters
TRequestTResponse
AsyncDuplexStreamingCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse>, AsyncDuplexStreamingCallContinuation<TRequest, TResponse>)
Intercepts an asynchronous invocation of a duplex streaming call.
public override AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> context, Interceptor.AsyncDuplexStreamingCallContinuation<TRequest, TResponse> continuation) where TRequest : class where TResponse : class
Parameters
contextClientInterceptorContext<TRequest, TResponse>The ClientInterceptorContext<TRequest, TResponse> associated with the current invocation.
continuationInterceptor.AsyncDuplexStreamingCallContinuation<TRequest, TResponse>The callback that continues the invocation process. This can be invoked zero or more times by the interceptor. The interceptor can invoke the continuation passing the given context argument, or substitute as it sees fit.
Returns
- AsyncDuplexStreamingCall<TRequest, TResponse>
An instance of AsyncDuplexStreamingCall<TRequest, TResponse> representing an asynchronous duplex-streaming invocation. The interceptor can simply return the return value of the continuation delegate passed to it intact, or construct its own substitute as it sees fit.
Type Parameters
TRequestTResponse
AsyncServerStreamingCall<TRequest, TResponse>(TRequest, ClientInterceptorContext<TRequest, TResponse>, AsyncServerStreamingCallContinuation<TRequest, TResponse>)
Intercepts an asynchronous invocation of a streaming remote call.
public override AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, TResponse> context, Interceptor.AsyncServerStreamingCallContinuation<TRequest, TResponse> continuation) where TRequest : class where TResponse : class
Parameters
requestTRequestThe request message of the invocation.
contextClientInterceptorContext<TRequest, TResponse>The ClientInterceptorContext<TRequest, TResponse> associated with the current invocation.
continuationInterceptor.AsyncServerStreamingCallContinuation<TRequest, TResponse>The callback that continues the invocation process. This can be invoked zero or more times by the interceptor. The interceptor can invoke the continuation passing the given request value and context arguments, or substitute them as it sees fit.
Returns
- AsyncServerStreamingCall<TResponse>
An instance of AsyncServerStreamingCall<TResponse> representing an asynchronous server-streaming invocation. The interceptor can simply return the return value of the continuation delegate passed to it intact, or construct its own substitute as it sees fit.
Type Parameters
TRequestTResponse
AsyncUnaryCall<TRequest, TResponse>(TRequest, ClientInterceptorContext<TRequest, TResponse>, AsyncUnaryCallContinuation<TRequest, TResponse>)
Intercepts an asynchronous invocation of a simple remote call.
public override AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, TResponse> context, Interceptor.AsyncUnaryCallContinuation<TRequest, TResponse> continuation) where TRequest : class where TResponse : class
Parameters
requestTRequestThe request message of the invocation.
contextClientInterceptorContext<TRequest, TResponse>The ClientInterceptorContext<TRequest, TResponse> associated with the current invocation.
continuationInterceptor.AsyncUnaryCallContinuation<TRequest, TResponse>The callback that continues the invocation process. This can be invoked zero or more times by the interceptor. The interceptor can invoke the continuation passing the given request value and context arguments, or substitute them as it sees fit.
Returns
- AsyncUnaryCall<TResponse>
An instance of AsyncUnaryCall<TResponse> representing an asynchronous unary invocation. The interceptor can simply return the return value of the continuation delegate passed to it intact, or construct its own substitute as it sees fit.
Type Parameters
TRequestTResponse
BlockingUnaryCall<TRequest, TResponse>(TRequest, ClientInterceptorContext<TRequest, TResponse>, BlockingUnaryCallContinuation<TRequest, TResponse>)
Intercepts a blocking invocation of a simple remote call.
public override TResponse BlockingUnaryCall<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, TResponse> context, Interceptor.BlockingUnaryCallContinuation<TRequest, TResponse> continuation) where TRequest : class where TResponse : class
Parameters
requestTRequestThe request message of the invocation.
contextClientInterceptorContext<TRequest, TResponse>The ClientInterceptorContext<TRequest, TResponse> associated with the current invocation.
continuationInterceptor.BlockingUnaryCallContinuation<TRequest, TResponse>The callback that continues the invocation process. This can be invoked zero or more times by the interceptor. The interceptor can invoke the continuation passing the given request value and context arguments, or substitute them as it sees fit.
Returns
- TResponse
The response message of the current invocation. The interceptor can simply return the return value of the continuation delegate passed to it intact, or an arbitrary value as it sees fit.
Type Parameters
TRequestTResponse