Thank you Carl Mastrangelo. That was very helpful!
For those who may see this question in the future below is my updated code
that works. Notice how setting the $metaData array uses the HTTP2 header
key as the array key, and the *header value is and array containing a
string of the value*.
$options = [
'credentials' => $this->credentialsObject,
'update_metadata' => function($metaData){
$metaData['authorization'] = ['Bearer ' . $this->token];
return $metaData;
}
];
$client = new OrganizationServiceClient($this->url,$options);
$r = new \Google\Protobuf\GPBEmpty();
list($data,$status) = $client->list($r)->wait();
On Monday, September 10, 2018 at 11:39:08 AM UTC-6, Carl Mastrangelo wrote:
>
> In gRPC, Headers and metadata are the same thing. The formatting for
> headers should follow normal HTTP rules, such as ignoring case for the
> header key, and only using the right ascii letters in the value. You can
> find the rules here:
> https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md
>
>
>
> On Monday, September 10, 2018 at 9:40:53 AM UTC-7, [email protected]
> wrote:
>>
>>
>> I am attempting to set some HTTP headers in gRPC client call written in
>> PHP. I cannot find anything specifying how to do this in PHP. From reading
>> docs for other languages I have come to think that headers are specified in
>> the client metadata. However, I can't find anything on how these should be
>> formatted, and all the formats I try don't seem to work. Here is my code:
>>
>>
>> $options = [
>> 'credentials' => $this->credentialsObject,
>> 'update_metadata' => function($metaData){
>> $metaData['headers'] = ['Authorization' => 'Bearer ' .
>> $this->token];
>> return $metaData;
>> }
>> ];
>>
>> $client = new OrganizationServiceClient($this->url,$options);
>>
>> $r = new \Google\Protobuf\GPBEmpty();
>>
>> list($data,$status) = $client->list($r)->wait();
>>
>>
>> Any help or pointers would be appreciated. I'm been working on this for a
>> few days now and feel like I've trying everything I can think of.
>>
>> 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/69069c5b-8a22-4859-9009-3ead1a402392%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.