如何在gRPC中使用Oauth2进行用户身份验证

(I am pretty new in grpc and golang)

I have a website that uses grpc-web package to communicate to a banckend grpc api server in golang. I need user authentication with github. But I am having difficulties in understanding how to use oauth2 token based authentication in grpc. I will appreciate if you can share your idea.

It looks like the way to use OAuth2 with grpc-web is to add the header to the metadata object which is the second argument to each rpc call.

my_grpc_web_client.MyMethod(myRequestProto, {Authorization: "Bearer <token>"});

References: https://github.com/grpc/grpc-web/issues/351 , specifically https://github.com/grpc/grpc-web/issues/351#issuecomment-436050409