This example demonstrates how to implement a gRPC server with Google Cloud Endpoints and HTTP/JSON Transcoding.
virtualenv bookstore-env
source bookstore-env/bin/activate
Install all the Python dependencies:
pip install -r requirements.txt
Install the gRPC libraries and tools
To run the server:
python bookstore_server.py
The -h
command line flag shows the various settings available.
To run the client:
python bookstore_client.py
As with the server, the -h
command line flag shows the various settings
available.
To run the script:
python jwt_token_gen.py --file=account_file --audiences=audiences --issuer=issuer
The output can be used as "--auth_token" for bookstore_client.py
The bookstore gRPC API is defined by bookstore.proto
The API client stubs and server interfaces are generated by tools.
To make it easier to get something up and running, we've included the generated code in the sample distribution. To modify the sample or create your own gRPC API definition, you'll need to update the generated code. To do this, once the gRPC libraries and tools are installed, run:
GOOGLEAPIS=/path/to/googleapis
git clone https://github.com/googleapis/googleapis $GOOGLEAPIS
python -m grpc.tools.protoc \
--include_imports \
--include_source_info \
--proto_path=. \
--proto_path=$GOOGLEAPIS \
--python_out=. \
--grpc_python_out=. \
--descriptor_set_out=api_descriptor.pb \
bookstore.proto