ghz icon indicating copy to clipboard operation
ghz copied to clipboard

How to pass the authorization token as header information

Open sharathchandramg opened this issue 2 years ago • 8 comments

Hi, I have my grpc service behind an API gateway. The gateway protects the service using an API key. I am able to use the above using grpcurl as follows:

grpcurl \
-H 'Authorization:<api_key>\
-d '{}' \
<endpoint>.cloudapp.azure.com:8080 \
<namespace>.HelloService/SayHello

I want to load test the same thing using ghz and I am facing issues in calling using the metadata

ghz \
-m '{"Authorization" : "<api_key>"}' \
--call <namespace>..HelloService/SayHello \
-d '{}' \
<endpoint>.cloudapp.azure.com:8080

I keep getting the error

rpc error: code = Unauthenticated desc = unexpected HTTP status code received from server: 401 (Unauthorized); transport: received unexpected content-type "application/json"

sharathchandramg avatar Aug 23 '23 14:08 sharathchandramg

Also having this issue

KeganHollern avatar Oct 19 '23 19:10 KeganHollern

We are also running into the same issue. Requests work fine with grpcurl but not with ghz

Our Header format is Authorization: Bearer <token>.

is-jonreeves avatar Nov 17 '23 19:11 is-jonreeves

Try ghz --metadata="{\"authorization\": \"Bearer $TOKEN\"}" It works fine for me.

GoToCoding avatar Dec 07 '23 18:12 GoToCoding

I have already tried many different ways to do that, and it still doesn't work with Ghz, but it perfectly works with grpcurl.

jwillker avatar Aug 01 '24 23:08 jwillker