aboutsummaryrefslogtreecommitdiffhomepage
path: root/grpc-auth-support.md
diff options
context:
space:
mode:
authorGravatar Stanley Cheung <stanleycheung@google.com>2015-06-23 17:35:04 -0700
committerGravatar Stanley Cheung <stanleycheung@google.com>2015-06-23 17:35:04 -0700
commit40dc223f07ec31e0b9acf1796b574109cf965c3b (patch)
tree65dc12186a67096d8db531d1afbedfcbe82038bc /grpc-auth-support.md
parentbe879b8d425077c429fb2a9e51f77edcbcbf91ca (diff)
Add PHP Google Auth example
Diffstat (limited to 'grpc-auth-support.md')
-rw-r--r--grpc-auth-support.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/grpc-auth-support.md b/grpc-auth-support.md
index 9b97203276..aff952a050 100644
--- a/grpc-auth-support.md
+++ b/grpc-auth-support.md
@@ -174,3 +174,24 @@ if (authorization.IsCreateScopedRequired)
var client = new Greeter.GreeterClient(channel,
new StubConfiguration(OAuth2InterceptorFactory.Create(credential)));
```
+
+###Authenticating with Google (PHP)
+```php
+// Base case - No encryption/authorization
+$client = new helloworld\GreeterClient(
+ new Grpc\BaseStub('localhost:50051', []));
+...
+
+// Authenticating with Google
+// the environment variable "GOOGLE_APPLICATION_CREDENTIALS" needs to be set
+$scope = "https://www.googleapis.com/auth/grpc-testing";
+$auth = Google\Auth\ApplicationDefaultCredentials::getCredentials($scope);
+$opts = [
+ 'credentials' => Grpc\Credentials::createSsl(file_get_contents('ca.pem'));
+ 'update_metadata' => $auth->getUpdateMetadataFunc(),
+];
+
+$client = new helloworld\GreeterClient(
+ new Grpc\BaseStub('localhost:50051', $opts));
+
+```