diff --git a/src/csharp/Grpc.Auth/AuthInterceptors.cs b/src/csharp/Grpc.Auth/AuthInterceptors.cs index 5a5ca7edc711ddfb796bf093fa896571a71e5a84..61338f7f0e26f79eb520f139f4d6e8fc90a4e08c 100644 --- a/src/csharp/Grpc.Auth/AuthInterceptors.cs +++ b/src/csharp/Grpc.Auth/AuthInterceptors.cs @@ -54,7 +54,7 @@ namespace Grpc.Auth /// </summary> public static HeaderInterceptor FromCredential(ITokenAccess credential) { - return new HeaderInterceptor((authUri, metadata) => + return new HeaderInterceptor((method, authUri, metadata) => { // TODO(jtattermusch): Rethink synchronous wait to obtain the result. var accessToken = credential.GetAccessTokenForRequestAsync(authUri, CancellationToken.None) @@ -70,7 +70,7 @@ namespace Grpc.Auth public static HeaderInterceptor FromAccessToken(string accessToken) { Preconditions.CheckNotNull(accessToken); - return new HeaderInterceptor((authUri, metadata) => + return new HeaderInterceptor((method, authUri, metadata) => { metadata.Add(CreateBearerTokenHeader(accessToken)); }); diff --git a/src/csharp/Grpc.Core/ClientBase.cs b/src/csharp/Grpc.Core/ClientBase.cs index 751d2d260fe163d1af0afd64dc3c282daaf46a60..7bc100ca60372fe1cee45c8073c2bef8b055f145 100644 --- a/src/csharp/Grpc.Core/ClientBase.cs +++ b/src/csharp/Grpc.Core/ClientBase.cs @@ -40,7 +40,7 @@ namespace Grpc.Core /// <summary> /// Interceptor for call headers. /// </summary> - public delegate void HeaderInterceptor(string authUri, Metadata metadata); + public delegate void HeaderInterceptor(IMethod method, string authUri, Metadata metadata); /// <summary> /// Base class for client-side stubs. @@ -107,7 +107,7 @@ namespace Grpc.Core options = options.WithHeaders(new Metadata()); } var authUri = authUriBase != null ? authUriBase + method.ServiceName : null; - interceptor(authUri, options.Headers); + interceptor(method, authUri, options.Headers); } return new CallInvocationDetails<TRequest, TResponse>(channel, method, Host, options); } diff --git a/src/csharp/Grpc.Core/Method.cs b/src/csharp/Grpc.Core/Method.cs index 4c208b4a263068b52529238a816781263b913267..4c53285893e013c16d06c43352f4a9fc800b5dde 100644 --- a/src/csharp/Grpc.Core/Method.cs +++ b/src/csharp/Grpc.Core/Method.cs @@ -54,10 +54,37 @@ namespace Grpc.Core DuplexStreaming } + /// <summary> + /// A non-generic representation of a remote method. + /// </summary> + public interface IMethod + { + /// <summary> + /// Gets the type of the method. + /// </summary> + MethodType Type { get; } + + /// <summary> + /// Gets the name of the service to which this method belongs. + /// </summary> + string ServiceName { get; } + + /// <summary> + /// Gets the unqualified name of the method. + /// </summary> + string Name { get; } + + /// <summary> + /// Gets the fully qualified name of the method. On the server side, methods are dispatched + /// based on this name. + /// </summary> + string FullName { get; } + } + /// <summary> /// A description of a remote method. /// </summary> - public class Method<TRequest, TResponse> + public class Method<TRequest, TResponse> : IMethod { readonly MethodType type; readonly string serviceName; diff --git a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs index 1047f2efc104a668eed3ddcdb9798ae177db8679..f4b0a1028f99ec23d26f793de32bc7369a48aae5 100644 --- a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs +++ b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs @@ -409,7 +409,7 @@ namespace Grpc.IntegrationTesting .Build(); var headers = new Metadata(); - headerInterceptor("", headers); + headerInterceptor(null, "", headers); var response = client.UnaryCall(request, headers: headers); Assert.AreEqual(AuthScopeResponse, response.OauthScope);