diff --git a/src/php/ext/grpc/call_credentials.c b/src/php/ext/grpc/call_credentials.c index 06c6fc0566a..285c4e7c856 100644 --- a/src/php/ext/grpc/call_credentials.c +++ b/src/php/ext/grpc/call_credentials.c @@ -183,7 +183,9 @@ void plugin_get_metadata(void *ptr, grpc_auth_metadata_context context, zval *arg; zval *retval; MAKE_STD_ZVAL(arg); - ZVAL_STRING(arg, context.service_url, 1); + object_init(arg); + add_property_string(arg, "service_url", context.service_url, true); + add_property_string(arg, "method_name", context.method_name, true); params[0] = &arg; state->fci->param_count = 1; state->fci->params = params; diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index 45aa8bfc6bf..ee604a387cc 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -191,8 +191,10 @@ function oauth2AuthToken($stub, $args) 'invalid email returned'); } -function updateAuthMetadataCallback($authUri) +function updateAuthMetadataCallback($context) { + $authUri = $context->service_url; + $methodName = $context->method_name; $auth_credentials = ApplicationDefaultCredentials::getCredentials(); return $auth_credentials->updateMetadata($metadata = [], $authUri); diff --git a/src/php/tests/unit_tests/CallCredentialsTest.php b/src/php/tests/unit_tests/CallCredentialsTest.php index aac21d4c492..09184127816 100644 --- a/src/php/tests/unit_tests/CallCredentialsTest.php +++ b/src/php/tests/unit_tests/CallCredentialsTest.php @@ -69,9 +69,10 @@ class CallCredentialsTest extends PHPUnit_Framework_TestCase unset($this->server); } - public function callbackFunc($service_url) + public function callbackFunc($context) { - $this->assertTrue(is_string($service_url)); + $this->assertTrue(is_string($context->service_url)); + $this->assertTrue(is_string($context->method_name)); return ['k1' => ['v1'], 'k2' => ['v2']]; }