Python grpc.AuthMetadataContext() Examples
The following are 11
code examples of grpc.AuthMetadataContext().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
grpc
, or try the search function
.
Example #1
Source File: test_grpc.py From google-auth-library-python with Apache License 2.0 | 6 votes |
def test_call_no_refresh(self): credentials = CredentialsStub() request = mock.create_autospec(transport.Request) plugin = google.auth.transport.grpc.AuthMetadataPlugin(credentials, request) context = mock.create_autospec(grpc.AuthMetadataContext, instance=True) context.method_name = mock.sentinel.method_name context.service_url = mock.sentinel.service_url callback = mock.create_autospec(grpc.AuthMetadataPluginCallback) plugin(context, callback) time.sleep(2) callback.assert_called_once_with( [(u"authorization", u"Bearer {}".format(credentials.token))], None )
Example #2
Source File: test_grpc.py From google-auth-library-python with Apache License 2.0 | 6 votes |
def test_call_refresh(self): credentials = CredentialsStub() credentials.expiry = datetime.datetime.min + _helpers.CLOCK_SKEW request = mock.create_autospec(transport.Request) plugin = google.auth.transport.grpc.AuthMetadataPlugin(credentials, request) context = mock.create_autospec(grpc.AuthMetadataContext, instance=True) context.method_name = mock.sentinel.method_name context.service_url = mock.sentinel.service_url callback = mock.create_autospec(grpc.AuthMetadataPluginCallback) plugin(context, callback) time.sleep(2) assert credentials.token == "token1" callback.assert_called_once_with( [(u"authorization", u"Bearer {}".format(credentials.token))], None )
Example #3
Source File: auth.py From tensorboard with Apache License 2.0 | 6 votes |
def __call__(self, context, callback): """Passes authorization metadata into the given callback. Args: context (grpc.AuthMetadataContext): The RPC context. callback (grpc.AuthMetadataPluginCallback): The callback that will be invoked to pass in the authorization metadata. """ headers = {} self._credentials.before_request( self._request, context.method_name, context.service_url, headers ) id_token = getattr(self._credentials, "id_token", None) if id_token: self._credentials.apply(headers, token=id_token) else: logger.error("Failed to find ID token credentials") # Pass headers as key-value pairs to match CallCredentials metadata. callback(list(headers.items()), None)
Example #4
Source File: grpc.py From google-auth-library-python with Apache License 2.0 | 5 votes |
def __call__(self, context, callback): """Passes authorization metadata into the given callback. Args: context (grpc.AuthMetadataContext): The RPC context. callback (grpc.AuthMetadataPluginCallback): The callback that will be invoked to pass in the authorization metadata. """ callback(self._get_authorization_headers(context), None)
Example #5
Source File: grpc.py From alfred-gmail with MIT License | 5 votes |
def __call__(self, context, callback): """Passes authorization metadata into the given callback. Args: context (grpc.AuthMetadataContext): The RPC context. callback (grpc.AuthMetadataPluginCallback): The callback that will be invoked to pass in the authorization metadata. """ callback(self._get_authorization_headers(context), None)
Example #6
Source File: grpc.py From luci-py with Apache License 2.0 | 5 votes |
def __call__(self, context, callback): """Passes authorization metadata into the given callback. Args: context (grpc.AuthMetadataContext): The RPC context. callback (grpc.AuthMetadataPluginCallback): The callback that will be invoked to pass in the authorization metadata. """ callback(self._get_authorization_headers(context), None)
Example #7
Source File: grpc.py From luci-py with Apache License 2.0 | 5 votes |
def __call__(self, context, callback): """Passes authorization metadata into the given callback. Args: context (grpc.AuthMetadataContext): The RPC context. callback (grpc.AuthMetadataPluginCallback): The callback that will be invoked to pass in the authorization metadata. """ callback(self._get_authorization_headers(context), None)
Example #8
Source File: grpc.py From luci-py with Apache License 2.0 | 5 votes |
def __call__(self, context, callback): """Passes authorization metadata into the given callback. Args: context (grpc.AuthMetadataContext): The RPC context. callback (grpc.AuthMetadataPluginCallback): The callback that will be invoked to pass in the authorization metadata. """ callback(self._get_authorization_headers(context), None)
Example #9
Source File: grpc.py From luci-py with Apache License 2.0 | 5 votes |
def __call__(self, context, callback): """Passes authorization metadata into the given callback. Args: context (grpc.AuthMetadataContext): The RPC context. callback (grpc.AuthMetadataPluginCallback): The callback that will be invoked to pass in the authorization metadata. """ callback(self._get_authorization_headers(context), None)
Example #10
Source File: grpc.py From luci-py with Apache License 2.0 | 5 votes |
def __call__(self, context, callback): """Passes authorization metadata into the given callback. Args: context (grpc.AuthMetadataContext): The RPC context. callback (grpc.AuthMetadataPluginCallback): The callback that will be invoked to pass in the authorization metadata. """ callback(self._get_authorization_headers(context), None)
Example #11
Source File: grpc.py From aws-kube-codesuite with Apache License 2.0 | 5 votes |
def __call__(self, context, callback): """Passes authorization metadata into the given callback. Args: context (grpc.AuthMetadataContext): The RPC context. callback (grpc.AuthMetadataPluginCallback): The callback that will be invoked to pass in the authorization metadata. """ callback(self._get_authorization_headers(context), None)