-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using protobuf-nt.grpc without .proto files with jwt authentication #325
Comments
There seems to be a mix of protobuf-net.Grpc code-first style and Google .proto-first style; I want to be 100% sure what the scenario is here - which approach are you using at the server? What would I need to repro this? Protobuf-net.Grpc usually uses CallContext, to allow a shared client/server API, but that exposes a ServerCallContext if required. |
I don't know how to explain it but I uploaded the project to github. here I get the token ` using var channel = GrpcChannel.ForAddress("https://localhost:5004");
and headers, in my understanding, are being passed as metadata, but here ` public class GreeterService : IGreeterService
|
It's not a special project, I just tried to make a mix of two examples I found on the internet, in fact I had made a more elaborate project but I made this simplified one to serve as an example for the problem, sorry for the inconvenience but I'm new to this area |
I tried to create a grpc client server project using protobuf-grpc.net with jwt authentication. I even managed to obtain the authentication token, however the examples I find the token must be attached to a metadata and then sent to greetservice which needs servercallcontext to carry out the authentication and it always tells me that it is impossible to convert metadata to servercallcontext. the interesting thing is that without using protobuf-net.grpc but using .proto files it works
IAuthenticationService authenticationClient = Channel.CreateGrpcService<IAuthenticationService>(); AuthenticationRequest authenticationRequest = new AuthenticationRequest { UserName = "admin", Password = "admin" }; Responses.AuthenticationResponse authenticationResponse = await authenticationClient.Authenticate(authenticationRequest); Headers = new Metadata { { "Authorization", $"Bearer {authenticationResponse.AccessToken}" } };
Cliente_pergunta input = new Cliente_pergunta { Name =i.ToString()+ " Lindo" }; Servidor_Responde reply = await Canal.GetInstance().Client.SayHelloAsync(input,Headers);
passing to
public override Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context) { return Task.FromResult(new HelloReply { Message = "Hello " + request.Name }); }
However, I get the error saying that it is impossible to convert from grpc.Core.Metadata to grpc.Core.ServerCallContext
The text was updated successfully, but these errors were encountered: