SlideShare a Scribd company logo
Understanding gRPC
Authentication Methods
Developer Week SF 2018
Anthony Chow
Cephas Security Solutions
Auth0 Ambassador | VMware vExpert
Feb 7, 2018
Twitter: @vCloudernBeer
Image source: https://github.com/cncf/landscape
Image source: https://github.com/cncf/landscape
Image source: https://katacontainers.io/img/kata-explained1-thumb@2x.png
What is gRPC?
 gRPC can be summarized as protocol buffers running
over HTTP/2 with multiple programming language
support.
Image source: grpc.io
Protocol Buffer
 Protocol buffer is one form of Interface Definition
Language for structured data serialization and de-
serialization between two parties and are transmitted
over a network in binary forms.
Image source: Google gRPC meetup kit
Install Protobuf 3 on
Ubuntu 16.04
• curl -OL
https://github.com/google/protobuf/releases/download/v3
.5.0/protoc-3.5.0-linux-x86_64.zip
• unzip protoc-3.5.0-linux-x86_64.zip -d protoc3
• sudo mv protoc3/bin/* /usr/local/bin/
• sudo mv protoc3/include/* /usr/local/include/
Service Definition
source: Google gRPC meetup kit
HTTP/2
 Hypertext Transfer Protocol Version 2 (HTTP/2) is
defined by RFC 7540 aimed at providing better
performance for HTTP traffics with bi-directional
streaming and flow control on a single TCP connection.
Source: Google gRPC meetup kit
Multi-language Support
Image source: Google gRPC meetup kit
gRPC Conceptssource: https://grpc.io/docs/guides/concepts.html
 Service Definition
 Using the API surface
 Synchronous vs asynchronous
 RPC life cycle
o Unary
o Client Streaming
o Server Streaming
o Bi-directional Streaming
 Deadlines/Timeouts
 RPC termination
 Cancelling RPCs
 Metadata
 Channels
Ruby Service
gRPC
server Go Service
gRPC
server
gRPC
Stub
Java Service
gRPC
Stub
Python Service
gRPC
server
gRPC
Stub
Multi-language supportsource: Google gRPC meetup kit
gRPC Request and Response
source: grpc.io
Who uses gRPCsource: Google gRPC meetup kit
Resource for gRPCsource: Google gRPC meetup kit
Documentation and Code
● http://www.grpc.io/
● https://github.com/grpc
● https://github.com/grpc-ecosystem
Help and Support
● https://gitter.im/grpc/grpc
● https://groups.google.com/forum/#!forum/grpc-io
Getting started with gRPC
 https://grpc.io/docs/quickstart/
 https://grpc.io/docs/tutorials/basic/python.html
1. Define the gRPC service and the method request and
response types using protocol buffers
2. Generate the gRPC client and server interfaces from your
.proto service definition.
3. Create the server
4. Create the client
gRPC frame format
• Wireshark demo
Authentication vs
Authorization
 Authentication – determine who you claim to be by the
credential you provide.
o Something you have – smart token device
o Something you know - password
o Something you are – fingerprint
 Authorization – based on user credential grant access
to resource
o Read-Write
o Read only
o Delete
gRPC built-in
Authentication Methods
 SSL/TLS
 Token-based authentication with Google
o JWT
o OAuth Access Token
 Credentials plugin API - allows developers to plug in their
own type of credentials
Credential Types
 Channel credential
 Call credential
Base case - No encryption
or authentication
import grpc
import helloworld_pb2
channel = grpc.insecure_channel('localhost:50051')
stub = helloworld_pb2.GreeterStub(channel)
With server
authentication SSL/TLS
import grpc
import helloworld_pb2
creds = grpc.ssl_channel_credentials(open('roots.pem').read())
channel = grpc.secure_channel('myservice.example.com:443',
creds)
stub = helloworld_pb2.GreeterStub(channel)
Authenticate with Google
using a JWT
import grpc
import helloworld_pb2
from google import auth as google_auth
from google.auth import jwt as google_auth_jwt
from google.auth.transport import grpc as google_auth_transport_grpc
credentials, _ = google_auth.default()
jwt_creds = google_auth_jwt.OnDemandCredentials.from_signing_credentials(
credentials)
channel = google_auth_transport_grpc.secure_authorized_channel( jwt_creds,
None,
'greeter.googleapis.com:443')
stub = helloworld_pb2.GreeterStub(channel)
Authenticate with Google
using an OAuth2 token
import grpc
import helloworld_pb2
from google import auth as google_auth
from google.auth.transport import grpc as google_auth_transport_grpc
from google.auth.transport import requests as google_auth_transport_requests
credentials, _ = google_auth.default(scopes=(scope,))
request = google_auth_transport_requests.Request()
channel = google_auth_transport_grpc.secure_authorized_channel(
credentials,
request,
'greeter.googleapis.com:443')
stub = helloworld_pb2.GreeterStub(channel)
Authenticate with 3rd
Party
• AuthMetadataPlugin
• …/src/python/grpcio_tests/unit/_auth_test.py
SSL/TLS
 SSL – Secure Socket Layer (older standard)
o Version 2 and version 3
 TLS – Transport Layer Security (newer standard)
o Version 1.1, 1.2 and 1.3
 Asymmetric encryption
o Private Key and Public key
 Symmetric encryption
o Symmetric key
 Hashing
 Digital Certificate – e.g. X.509
SSL - Handshake
Image source: https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.1.0/com.ibm.mq.doc/sy10660a.gif
SSL – X.509 Digital
Certificate
Image source: https://www.ibm.com/support/knowledgecenter/en/SSB23S_1.1.0.14/gtps7/ssldig17.gif
gRPC with TLS
• Python “helloworld” demo with TLS.
gRPC code base
• https://github.com/grpc/
• https://github.com/GoogleCloudPlatform/google-auth-
library-python
JWT- JSON Web Token
Image source: youtube.com
Resources for JSON Web
Token
• https://auth0.com/learn/json-web-tokens/
• https://jwt.io/introduction/
• https://scotch.io/tutorials/the-anatomy-of-a-json-
web-token
• https://auth0.com/e-books/jwt-handbook
OAuth-2
 “Open Authentication” (?)
 Authorization delegation
 An authorization framework
 Defined by RFC 6749 and 6750
 OAuth 1 is defined by RFC 5849
 OAuth 1 and OAuth 2 are not compatible
OAuth2 Actors
Image source: https://www.linkedin.com/pulse/microservices-security-openid-connect-manish-singh/
OAuth2 Flows (grants)
image source: https://www.slideshare.net/rcandidosilva/javaone-2014-securing-restful-resources-with-oauth2
OAuth2 Authorization Grants
 Different ways of getting a token
o Authorization code,
o Implicit grant,
o Resource owner password credentials and
o Client credentials
 Which OAuth 2.0 flow should I use?
OAuth2 Tokens
• Access Token
• Refresh Token
OAuth2 simplified view
 Image source: https://www.hivemq.com/wp-content/uploads/oauth-simple.png
Resource for OAuth2
• RFC 6749 - https://tools.ietf.org/html/rfc6749
• RFC 6750 - https://tools.ietf.org/html/rfc6750
• https://auth0.com/docs/protocols/oauth2
• https://developers.google.com/oauthplayground/
Google Cloud Endpoints
for gRPC
 Choosing an Authentication Method
o API Keys
o Firebase authentication
o Auth0 authentication
o Google authentication
o Google authentication and Service Account
Examples show how to set up
ESP in a gRPC service
authentication:
providers:
- id: auth0_jwk
# Replace YOUR-ACCOUNT-NAME with your service account's email address.
issuer: https://DevWeekSF2018.auth0.com/
jwks_uri: "https://DevWeekSF2018.auth0.com/.well-known/jwks.json"
rules:
- selector: "*"
requirements:
- provider_id: auth0_jwk
Calling an authenticated
method from gRPC
def run(host, port, api_key, auth_token, timeout):
"""Makes a basic ListShelves call against a gRPC Bookstore server."""
channel = grpc.insecure_channel('{}:{}'.format(host, port))
stub = bookstore_pb2.BookstoreStub(channel)
metadata = []
if api_key:
metadata.append(('x-api-key', api_key))
if auth_token:
metadata.append(('authorization', 'Bearer ' + auth_token))
shelves = stub.ListShelves(empty_pb2.Empty(), timeout, metadata=metadata)
print('ListShelves: {}'.format(shelves))
Setting up your Auth0
Thanks for
coming!

More Related Content

PPTX
Presentasi MIKROTIK ROUTERBOARD
PPTX
MEDIA PEMBELAJARAN ROUTING.pptx
PPTX
Arm cortex ( lpc 2148 ) based motor speed control
PPTX
MATERI SOSIALISASI PPDB JABAR-F28423DP.pptx
PDF
AKSI NYATA Melakukan Asesmen Awal pembelajarann_compressed.pdf
PPT
Kepemimpinan Dalam Gerakan Pramuka
PPTX
Persentasi Konfigurasi Mikrotik
PPTX
SALURAN TEGANGAN RENDAH 380/220 VOLT
Presentasi MIKROTIK ROUTERBOARD
MEDIA PEMBELAJARAN ROUTING.pptx
Arm cortex ( lpc 2148 ) based motor speed control
MATERI SOSIALISASI PPDB JABAR-F28423DP.pptx
AKSI NYATA Melakukan Asesmen Awal pembelajarann_compressed.pdf
Kepemimpinan Dalam Gerakan Pramuka
Persentasi Konfigurasi Mikrotik
SALURAN TEGANGAN RENDAH 380/220 VOLT

What's hot (20)

PDF
Panduan bantuan praktik kerja lapangan
PDF
Liturgi Ibadah sekolah kader komisariat migas.pdf
PPTX
Mengenal PBX
PDF
게임 인공지능 설계
PPTX
Ocean IoT platform guide
PDF
Solusi UTS Genap Praktikum Sistem Keamanan Jaringan - STMIK Bumigora
PDF
Laporan kerja praktek jaringankomputer
PDF
화자인식 기술 및 관련 연구 소개
PDF
PENYELESAIAN SOAL UKK - TKJ TAHUN 2018/2019 PAKET 1 (K13)
DOCX
SOAL ESSAY HOTS KOMPUTER JARINGAN DASAR KELAS X MULTIMEDIA
PDF
Instalasi dan Konfigurasi LXC Centos 7 pada Proxmox VE 5.1
PDF
Program kerja tkj_2020-2021
PDF
Profile BLC TELKOM
PPTX
Sistem Keamanan Jaringan
PDF
TOPIK MERDEKA BELAJAR A K S I N Y A T A P M M P E L A T I H A N M A N D I R I...
PPTX
Konsep Moderasi Beragam Kementerian Agama RI (1).pptx
PDF
Aksi Nyata Buku Non Teks Bermutu Dan Manfaatnya .pdf
PDF
스마일게이트 Orange farm 소개자료
PPT
Profesi di Bidang Teknologi Informasi
PPTX
Mengakhiri Pelaksanaan Proyek CCDP - IFAD, Pembangunan Masyarakat Pesisir
Panduan bantuan praktik kerja lapangan
Liturgi Ibadah sekolah kader komisariat migas.pdf
Mengenal PBX
게임 인공지능 설계
Ocean IoT platform guide
Solusi UTS Genap Praktikum Sistem Keamanan Jaringan - STMIK Bumigora
Laporan kerja praktek jaringankomputer
화자인식 기술 및 관련 연구 소개
PENYELESAIAN SOAL UKK - TKJ TAHUN 2018/2019 PAKET 1 (K13)
SOAL ESSAY HOTS KOMPUTER JARINGAN DASAR KELAS X MULTIMEDIA
Instalasi dan Konfigurasi LXC Centos 7 pada Proxmox VE 5.1
Program kerja tkj_2020-2021
Profile BLC TELKOM
Sistem Keamanan Jaringan
TOPIK MERDEKA BELAJAR A K S I N Y A T A P M M P E L A T I H A N M A N D I R I...
Konsep Moderasi Beragam Kementerian Agama RI (1).pptx
Aksi Nyata Buku Non Teks Bermutu Dan Manfaatnya .pdf
스마일게이트 Orange farm 소개자료
Profesi di Bidang Teknologi Informasi
Mengakhiri Pelaksanaan Proyek CCDP - IFAD, Pembangunan Masyarakat Pesisir
Ad

Similar to Understanding gRPC Authentication Methods (20)

PPTX
The new (is it really ) api stack
PDF
gRPC Design and Implementation
PDF
Networked APIs with swift
PDF
Creating Great REST and gRPC API Experiences (in Swift)
PDF
gRPC - RPC rebirth?
PPTX
Introduction to gRPC. Advantages and Disadvantages
PPTX
REST vs gRPC: Battle of API's
PDF
Fast and Reliable Swift APIs with gRPC
PPTX
Introduction to gRPC (Application) Presentation
PPTX
Introduction to gRPC Presentation (Java)
PDF
High Performance Python Microservice Communication
PDF
gRPC Overview
PDF
Building REST APIs using gRPC and Go
PPTX
Managing gRPC Services using Kong KONNECT and the KONG API Gateway
PPTX
CocoaConf: The Language of Mobile Software is APIs
PDF
Microservices Communication Patterns with gRPC
PDF
From '00s to '20s: from RESTful to gRPC
PDF
gRPC with java
PPTX
NGINX: HTTP/2 Server Push and gRPC
The new (is it really ) api stack
gRPC Design and Implementation
Networked APIs with swift
Creating Great REST and gRPC API Experiences (in Swift)
gRPC - RPC rebirth?
Introduction to gRPC. Advantages and Disadvantages
REST vs gRPC: Battle of API's
Fast and Reliable Swift APIs with gRPC
Introduction to gRPC (Application) Presentation
Introduction to gRPC Presentation (Java)
High Performance Python Microservice Communication
gRPC Overview
Building REST APIs using gRPC and Go
Managing gRPC Services using Kong KONNECT and the KONG API Gateway
CocoaConf: The Language of Mobile Software is APIs
Microservices Communication Patterns with gRPC
From '00s to '20s: from RESTful to gRPC
gRPC with java
NGINX: HTTP/2 Server Push and gRPC
Ad

More from Anthony Chow (14)

PPTX
Build your own Blockchain with the right tool for your application
PPT
Container security
PPT
MQTT security
PPTX
Api security with o auth2
PPTX
Container security
PPT
Container security
PPTX
V brownbag sept-14-2016
PPTX
Understanding the container landscape and it associated projects
PPTX
Getting over the barrier and start contributing to OpenStack
PPT
Introduction to go
PPTX
Micro segmentation – a perfect fit for microservices
PPTX
An overview of OpenStack for the VMware community
PPTX
VXLAN in the contemporary data center
PPT
What a Beginner Should Know About OpenStack
Build your own Blockchain with the right tool for your application
Container security
MQTT security
Api security with o auth2
Container security
Container security
V brownbag sept-14-2016
Understanding the container landscape and it associated projects
Getting over the barrier and start contributing to OpenStack
Introduction to go
Micro segmentation – a perfect fit for microservices
An overview of OpenStack for the VMware community
VXLAN in the contemporary data center
What a Beginner Should Know About OpenStack

Recently uploaded (20)

PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
cuic standard and advanced reporting.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Modernizing your data center with Dell and AMD
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Approach and Philosophy of On baking technology
PPTX
Big Data Technologies - Introduction.pptx
PDF
Electronic commerce courselecture one. Pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Machine learning based COVID-19 study performance prediction
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Empathic Computing: Creating Shared Understanding
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Reach Out and Touch Someone: Haptics and Empathic Computing
cuic standard and advanced reporting.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Modernizing your data center with Dell and AMD
Digital-Transformation-Roadmap-for-Companies.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Approach and Philosophy of On baking technology
Big Data Technologies - Introduction.pptx
Electronic commerce courselecture one. Pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
The Rise and Fall of 3GPP – Time for a Sabbatical?
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows

Understanding gRPC Authentication Methods

  • 1. Understanding gRPC Authentication Methods Developer Week SF 2018 Anthony Chow Cephas Security Solutions Auth0 Ambassador | VMware vExpert Feb 7, 2018 Twitter: @vCloudernBeer
  • 5. What is gRPC?  gRPC can be summarized as protocol buffers running over HTTP/2 with multiple programming language support. Image source: grpc.io
  • 6. Protocol Buffer  Protocol buffer is one form of Interface Definition Language for structured data serialization and de- serialization between two parties and are transmitted over a network in binary forms. Image source: Google gRPC meetup kit
  • 7. Install Protobuf 3 on Ubuntu 16.04 • curl -OL https://github.com/google/protobuf/releases/download/v3 .5.0/protoc-3.5.0-linux-x86_64.zip • unzip protoc-3.5.0-linux-x86_64.zip -d protoc3 • sudo mv protoc3/bin/* /usr/local/bin/ • sudo mv protoc3/include/* /usr/local/include/
  • 9. HTTP/2  Hypertext Transfer Protocol Version 2 (HTTP/2) is defined by RFC 7540 aimed at providing better performance for HTTP traffics with bi-directional streaming and flow control on a single TCP connection. Source: Google gRPC meetup kit
  • 10. Multi-language Support Image source: Google gRPC meetup kit
  • 11. gRPC Conceptssource: https://grpc.io/docs/guides/concepts.html  Service Definition  Using the API surface  Synchronous vs asynchronous  RPC life cycle o Unary o Client Streaming o Server Streaming o Bi-directional Streaming  Deadlines/Timeouts  RPC termination  Cancelling RPCs  Metadata  Channels
  • 12. Ruby Service gRPC server Go Service gRPC server gRPC Stub Java Service gRPC Stub Python Service gRPC server gRPC Stub Multi-language supportsource: Google gRPC meetup kit
  • 13. gRPC Request and Response source: grpc.io
  • 14. Who uses gRPCsource: Google gRPC meetup kit
  • 15. Resource for gRPCsource: Google gRPC meetup kit Documentation and Code ● http://www.grpc.io/ ● https://github.com/grpc ● https://github.com/grpc-ecosystem Help and Support ● https://gitter.im/grpc/grpc ● https://groups.google.com/forum/#!forum/grpc-io
  • 16. Getting started with gRPC  https://grpc.io/docs/quickstart/  https://grpc.io/docs/tutorials/basic/python.html 1. Define the gRPC service and the method request and response types using protocol buffers 2. Generate the gRPC client and server interfaces from your .proto service definition. 3. Create the server 4. Create the client
  • 17. gRPC frame format • Wireshark demo
  • 18. Authentication vs Authorization  Authentication – determine who you claim to be by the credential you provide. o Something you have – smart token device o Something you know - password o Something you are – fingerprint  Authorization – based on user credential grant access to resource o Read-Write o Read only o Delete
  • 19. gRPC built-in Authentication Methods  SSL/TLS  Token-based authentication with Google o JWT o OAuth Access Token  Credentials plugin API - allows developers to plug in their own type of credentials
  • 20. Credential Types  Channel credential  Call credential
  • 21. Base case - No encryption or authentication import grpc import helloworld_pb2 channel = grpc.insecure_channel('localhost:50051') stub = helloworld_pb2.GreeterStub(channel)
  • 22. With server authentication SSL/TLS import grpc import helloworld_pb2 creds = grpc.ssl_channel_credentials(open('roots.pem').read()) channel = grpc.secure_channel('myservice.example.com:443', creds) stub = helloworld_pb2.GreeterStub(channel)
  • 23. Authenticate with Google using a JWT import grpc import helloworld_pb2 from google import auth as google_auth from google.auth import jwt as google_auth_jwt from google.auth.transport import grpc as google_auth_transport_grpc credentials, _ = google_auth.default() jwt_creds = google_auth_jwt.OnDemandCredentials.from_signing_credentials( credentials) channel = google_auth_transport_grpc.secure_authorized_channel( jwt_creds, None, 'greeter.googleapis.com:443') stub = helloworld_pb2.GreeterStub(channel)
  • 24. Authenticate with Google using an OAuth2 token import grpc import helloworld_pb2 from google import auth as google_auth from google.auth.transport import grpc as google_auth_transport_grpc from google.auth.transport import requests as google_auth_transport_requests credentials, _ = google_auth.default(scopes=(scope,)) request = google_auth_transport_requests.Request() channel = google_auth_transport_grpc.secure_authorized_channel( credentials, request, 'greeter.googleapis.com:443') stub = helloworld_pb2.GreeterStub(channel)
  • 25. Authenticate with 3rd Party • AuthMetadataPlugin • …/src/python/grpcio_tests/unit/_auth_test.py
  • 26. SSL/TLS  SSL – Secure Socket Layer (older standard) o Version 2 and version 3  TLS – Transport Layer Security (newer standard) o Version 1.1, 1.2 and 1.3  Asymmetric encryption o Private Key and Public key  Symmetric encryption o Symmetric key  Hashing  Digital Certificate – e.g. X.509
  • 27. SSL - Handshake Image source: https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.1.0/com.ibm.mq.doc/sy10660a.gif
  • 28. SSL – X.509 Digital Certificate Image source: https://www.ibm.com/support/knowledgecenter/en/SSB23S_1.1.0.14/gtps7/ssldig17.gif
  • 29. gRPC with TLS • Python “helloworld” demo with TLS.
  • 30. gRPC code base • https://github.com/grpc/ • https://github.com/GoogleCloudPlatform/google-auth- library-python
  • 31. JWT- JSON Web Token Image source: youtube.com
  • 32. Resources for JSON Web Token • https://auth0.com/learn/json-web-tokens/ • https://jwt.io/introduction/ • https://scotch.io/tutorials/the-anatomy-of-a-json- web-token • https://auth0.com/e-books/jwt-handbook
  • 33. OAuth-2  “Open Authentication” (?)  Authorization delegation  An authorization framework  Defined by RFC 6749 and 6750  OAuth 1 is defined by RFC 5849  OAuth 1 and OAuth 2 are not compatible
  • 34. OAuth2 Actors Image source: https://www.linkedin.com/pulse/microservices-security-openid-connect-manish-singh/
  • 35. OAuth2 Flows (grants) image source: https://www.slideshare.net/rcandidosilva/javaone-2014-securing-restful-resources-with-oauth2
  • 36. OAuth2 Authorization Grants  Different ways of getting a token o Authorization code, o Implicit grant, o Resource owner password credentials and o Client credentials  Which OAuth 2.0 flow should I use?
  • 37. OAuth2 Tokens • Access Token • Refresh Token
  • 38. OAuth2 simplified view  Image source: https://www.hivemq.com/wp-content/uploads/oauth-simple.png
  • 39. Resource for OAuth2 • RFC 6749 - https://tools.ietf.org/html/rfc6749 • RFC 6750 - https://tools.ietf.org/html/rfc6750 • https://auth0.com/docs/protocols/oauth2 • https://developers.google.com/oauthplayground/
  • 40. Google Cloud Endpoints for gRPC  Choosing an Authentication Method o API Keys o Firebase authentication o Auth0 authentication o Google authentication o Google authentication and Service Account
  • 41. Examples show how to set up ESP in a gRPC service authentication: providers: - id: auth0_jwk # Replace YOUR-ACCOUNT-NAME with your service account's email address. issuer: https://DevWeekSF2018.auth0.com/ jwks_uri: "https://DevWeekSF2018.auth0.com/.well-known/jwks.json" rules: - selector: "*" requirements: - provider_id: auth0_jwk
  • 42. Calling an authenticated method from gRPC def run(host, port, api_key, auth_token, timeout): """Makes a basic ListShelves call against a gRPC Bookstore server.""" channel = grpc.insecure_channel('{}:{}'.format(host, port)) stub = bookstore_pb2.BookstoreStub(channel) metadata = [] if api_key: metadata.append(('x-api-key', api_key)) if auth_token: metadata.append(('authorization', 'Bearer ' + auth_token)) shelves = stub.ListShelves(empty_pb2.Empty(), timeout, metadata=metadata) print('ListShelves: {}'.format(shelves))