From e053c5605893debb353e702a6112fb1486176414 Mon Sep 17 00:00:00 2001 From: Alex Amies Date: Thu, 16 Apr 2020 17:17:19 -0700 Subject: [PATCH] Update README.md Minor changes. I worked through this successfully but the instructions in the README needed two minor changes. Also, I added the commands to test with authentication to Cloud Run. --- python/README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/python/README.md b/python/README.md index 24a2886..3e9961c 100644 --- a/python/README.md +++ b/python/README.md @@ -77,7 +77,7 @@ transport is well-supported. Now let's test the server out locally. First, we install dependencies. ```bash -virtualenv venv -p python3 +python3 -m venv venv source venv/bin/activate pip install -r requirements.txt ``` @@ -169,7 +169,7 @@ the `gcr.io` container registry, so we'll tag it accordingly. ```bash export GCP_PROJECT= -docker build -t gcr.io/$GCP_PROJECT/grpc-calculator:latest +docker build -t gcr.io/$GCP_PROJECT/grpc-calculator:latest . ``` The tag above will change based on your GCP project name. We're calling the @@ -251,3 +251,20 @@ grpcurl \ ``` And now you've got an auto-scaling calculator gRPC service! + +To send a request with authentication enabled for Cloud Run, type this command +from an environment where you have a service account enabled + +```bash +TOKEN=`gcloud auth print-identity-token --audiences https://${ENDPOINT}` +``` + +Then add the token to the request with the command + +```bash +grpcurl -H "Authorization: Bearer $TOKEN" \ + -proto calculator.proto \ + -d '{"first_operand": 2.0, "second_operand": 3.0, "operation": "ADD"}' \ + ${ENDPOINT}:443 \ + Calculator.Calculate +```