You can apply CallCredentials to ChannelCredentials through 
grpc.composite_channel_credentials. 
I believe its use is for authorization but it essentially adds metadata for 
every call. You need to connect to a secure channel to use it though.

transport_creds = grpc.ssl_channel_credentials(open('roots.pem').read())
def credentials(context, callback):
  callback([('key','value')], None)

auth_creds = grpc.metadata_call_credentials(credentials)
channel_creds = grpc.composite_channel_credentials(transport_creds, auth_creds)
channel = grpc.secure_channel('greeter.googleapis.com:443', channel_creds)


A better option might be to create a shim layer that just passes on the 
call while adding some metadata. Could probably achieve that with some 
__getattr__ magic


On Tuesday, February 14, 2017 at 12:16:42 PM UTC, [email protected] wrote:
>
> I'd like to add some metadata like token or version at each call, and 
> server should check it.
>
> I know how to add meta for each call (metadata argument), however, Is 
> there a way to add metadata globally for client?
>
> I know how to get metadata in each server context 
> (context.invocation_metadata()), however, is there something like 
> middleware to check it globally?
>
> Thanks!
>

-- 
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/0cfbfc0f-1fec-4cd2-b3bd-5dc86e838e31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to