Augment context in server interceptors - python

40 views
Skip to first unread message

Ant

unread,
Jun 23, 2025, 11:08:31 AM6/23/25
to grpc.io
Hi, 

I have a gRPC server. I want to protect some routes, ensuring only authenticated users can access them.

Ok, so you can use a server interceptor, as done in the [examples](https://github.com/grpc/grpc/blob/master/examples/python/auth/customized_auth_server.py#L35).

I want to be able to now augment the context, so that the `RpcHandlers` which are about to be called have the `user` field in the context and can use it directly (instead of having to replicate the authentication logic which has just been done by the interceptor).

It's the same question as [this one](https://github.com/grpc/grpc-go/issues/4363), but that one is for go - I am interested in python.

Is there a way to do this? 
Reply all
Reply to author
Forward
0 new messages