Example #1
0
def metadata_call_credentials(metadata_plugin, name=None):
    """Construct CallCredentials from an AuthMetadataPlugin.

  Args:
    metadata_plugin: An AuthMetadataPlugin to use for authentication.
    name: An optional name for the plugin.

  Returns:
    A CallCredentials.
  """
    from grpc import _plugin_wrapping  # pylint: disable=cyclic-import
    if name is None:
        try:
            effective_name = metadata_plugin.__name__
        except AttributeError:
            effective_name = metadata_plugin.__class__.__name__
    else:
        effective_name = name
    return CallCredentials(
        _plugin_wrapping.call_credentials_metadata_plugin(
            metadata_plugin, effective_name))
Example #2
0
def metadata_call_credentials(metadata_plugin, name=None):
    """Construct CallCredentials from an AuthMetadataPlugin.

  Args:
    metadata_plugin: An AuthMetadataPlugin to use as the authentication behavior
      in the created CallCredentials.
    name: A name for the plugin.

  Returns:
    A CallCredentials.
  """
    from grpc import _plugin_wrapping

    if name is None:
        try:
            effective_name = metadata_plugin.__name__
        except AttributeError:
            effective_name = metadata_plugin.__class__.__name__
    else:
        effective_name = name
    return CallCredentials(_plugin_wrapping.call_credentials_metadata_plugin(metadata_plugin, effective_name))
Example #3
0
def metadata_call_credentials(metadata_plugin, name=None):
    """Construct CallCredentials from an AuthMetadataPlugin.

  Args:
    metadata_plugin: An AuthMetadataPlugin to use for authentication.
    name: An optional name for the plugin.

  Returns:
    A CallCredentials.
  """
    from grpc import _plugin_wrapping  # pylint: disable=cyclic-import
    if name is None:
        try:
            effective_name = metadata_plugin.__name__
        except AttributeError:
            effective_name = metadata_plugin.__class__.__name__
    else:
        effective_name = name
    return CallCredentials(
        _plugin_wrapping.call_credentials_metadata_plugin(metadata_plugin,
                                                          effective_name))
Example #4
0
def metadata_call_credentials(metadata_plugin, name=None):
    """Construct CallCredentials from an AuthMetadataPlugin.

  Args:
    metadata_plugin: An AuthMetadataPlugin to use as the authentication behavior
      in the created CallCredentials.
    name: A name for the plugin.

  Returns:
    A CallCredentials.
  """
    from grpc import _plugin_wrapping
    if name is None:
        try:
            effective_name = metadata_plugin.__name__
        except AttributeError:
            effective_name = metadata_plugin.__class__.__name__
    else:
        effective_name = name
    return CallCredentials(
        _plugin_wrapping.call_credentials_metadata_plugin(
            metadata_plugin, effective_name))