What's the equivalent of `grpc.WithPerRPCCredentials` in C++?

Viewed 37

We have some Go code which uses JWT as per RPC credentials with gRPC. I'm trying to implement a client in C++, but I can't figure out what the equivalent of the grpc.WithPerRPCCredentials dial option is in C++. The Go code is like this:

type claims struct {
    claims map[string]string
    secure bool
}

func (c claims) GetRequestMetadata(ctx context.Context, a ...string) (map[string]string, error) {
    return c.claims, nil
}

func (c claims) RequireTransportSecurity() bool {
    return c.secure
}

fn connect() {
    clms := claims{
        claims: make(map[string]string),
        secure: !c.insecure,
    }
    clms.claims["token"] = ourJWT;
    conn, err := grpc.DialContext(context.Background(), addr, grpc.WithPerRPCCredentials(clms))
}   

What's the equivalent way in C++ to create credentials which attaches a JWT to each request?

1 Answers
Related