当前位置: 首页>>代码示例>>Python>>正文


Python grpc.metadata_call_credentials方法代码示例

本文整理汇总了Python中grpc.metadata_call_credentials方法的典型用法代码示例。如果您正苦于以下问题:Python grpc.metadata_call_credentials方法的具体用法?Python grpc.metadata_call_credentials怎么用?Python grpc.metadata_call_credentials使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在grpc的用法示例。


在下文中一共展示了grpc.metadata_call_credentials方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: lnd_client

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def lnd_client(self):
        if self._lnd_client is not None:
            return self._lnd_client
        auth_credentials = grpc.metadata_call_credentials(
            self.metadata_callback)

        credentials = grpc.composite_channel_credentials(
            self.get_cert_credentials(),
            auth_credentials)

        grpc_channel = grpc.secure_channel(
            f'{self.grpc_host}:{self.grpc_port}',
            credentials,
            options=self.grpc_options
        )
        self._lnd_client = lnrpc.LightningStub(grpc_channel)
        return self._lnd_client 
开发者ID:lightning-power-users,项目名称:node-launcher,代码行数:19,代码来源:lnd_client.py

示例2: combined_credentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def combined_credentials(self) -> grpc.CallCredentials:
        """
        Combine ssl and macaroon credentials
        :return: grpc.composite_channel_credentials
        """
        cert_creds = grpc.ssl_channel_credentials(self.tls_cert)
        auth_creds = grpc.metadata_call_credentials(self.metadata_callback)
        return grpc.composite_channel_credentials(cert_creds, auth_creds) 
开发者ID:willcl-ark,项目名称:lnd_grpc,代码行数:10,代码来源:base_client.py

示例3: get_rpc_channel

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def get_rpc_channel(host="localhost", port="10009", cert_path=None, macaroon_path=None):
    if not macaroon_path:
        raise Exception("need to specify a macaroon path!")

    def metadata_callback(context, callback):
        # for more info see grpc docs
        callback([('macaroon', macaroon)], None)

    # Due to updated ECDSA generated tls.cert we need to let gprc know that
    # we need to use that cipher suite otherwise there will be a handshake
    # error when we communicate with the lnd rpc server.
    os.environ["GRPC_SSL_CIPHER_SUITES"] = 'HIGH+ECDSA'

    if not cert_path:
        cert_path = os.path.expanduser('~/.lnd/tls.cert')

    assert isfile(cert_path) and os.access(cert_path, os.R_OK), \
        "File {} doesn't exist or isn't readable".format(cert_path)
    cert = open(cert_path, 'rb').read()

    with open(macaroon_path, 'rb') as f:
        macaroon_bytes = f.read()
        macaroon = codecs.encode(macaroon_bytes, 'hex')

    # build ssl credentials using the cert the same as before
    cert_creds = grpc.ssl_channel_credentials(cert)

    # now build meta data credentials
    auth_creds = grpc.metadata_call_credentials(metadata_callback)

    # combine the cert credentials and the macaroon auth credentials
    # such that every call is properly encrypted and authenticated
    combined_creds = grpc.composite_channel_credentials(cert_creds, auth_creds)

    # finally pass in the combined credentials when creating a channel
    return grpc.secure_channel('{}:{}'.format(host, port), combined_creds) 
开发者ID:rootzoll,项目名称:raspiblitz,代码行数:38,代码来源:client.py

示例4: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def getCredentials():
    sslCred = grpc.ssl_channel_credentials()

    authCred = grpc.metadata_call_credentials(credentials)

    return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

# gRPC channel 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:12,代码来源:grpc.py

示例5: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def getCredentials():
	sslCred = grpc.ssl_channel_credentials()
	authCred = grpc.metadata_call_credentials(credentials)
	return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

# TTS : getText2VoiceStream 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:10,代码来源:ex4_getText2VoiceStream.py

示例6: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def getCredentials():
    sslCred = grpc.ssl_channel_credentials()

    authCred = grpc.metadata_call_credentials(credentials)

    return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ### 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:10,代码来源:ex2_getVoice2Text.py

示例7: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def getCredentials():
	sslCred = grpc.ssl_channel_credentials()

	authCred = grpc.metadata_call_credentials(credentials)

	return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

# DIALOG : queryByText 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:12,代码来源:ex5_queryText.py

示例8: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def getCredentials():
	sslCred = grpc.ssl_channel_credentials()

	authCred = grpc.metadata_call_credentials(credentials)

	return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

# TTS : getText2VoiceUrl 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:12,代码来源:ex3_getText2VoiceUrl.py

示例9: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def getCredentials():
	with open('../data/ca-bundle.pem', 'rb') as f:
		trusted_certs = f.read()
	sslCred = grpc.ssl_channel_credentials(root_certificates=trusted_certs)

	authCred = grpc.metadata_call_credentials(credentials)

	return grpc.composite_channel_credentials(sslCred, authCred)

### KWS 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:12,代码来源:proj2_yt_mvp.py

示例10: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def getCredentials():
    with open('/home/pi/ai-makers-kit/data/ca-bundle.pem', 'rb') as f:
        trusted_certs = f.read()
    sslCred = grpc.ssl_channel_credentials(root_certificates=trusted_certs)
    authCred = grpc.metadata_call_credentials(credentials)
    return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

# TTS : getText2VoiceStream 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:12,代码来源:ex4_getText2VoiceStream.py

示例11: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def getCredentials():
    with open('../data/ca-bundle.pem', 'rb') as f:
        trusted_certs = f.read()
    sslCred = grpc.ssl_channel_credentials(root_certificates=trusted_certs)

    authCred = grpc.metadata_call_credentials(credentials)

    return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

### STT 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:14,代码来源:ex2_getVoice2Text.py

示例12: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def getCredentials():
    with open('../data/ca-bundle.pem', 'rb') as f:
        trusted_certs = f.read()
    sslCred = grpc.ssl_channel_credentials(root_certificates=trusted_certs)
    authCred = grpc.metadata_call_credentials(credentials)
    return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

# TTS : getText2VoiceStream 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:12,代码来源:ex4_getText2VoiceStream.py

示例13: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def getCredentials():
    sslCred = grpc.ssl_channel_credentials()
    authCred = grpc.metadata_call_credentials(credentials)
    return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ### 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:8,代码来源:user_auth.py

示例14: id_token_call_credentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def id_token_call_credentials(credentials):
    """Constructs `grpc.CallCredentials` using
    `google.auth.Credentials.id_token`.

    Args:
      credentials (google.auth.credentials.Credentials): The credentials to use.

    Returns:
      grpc.CallCredentials: The call credentials.
    """
    request = google.auth.transport.requests.Request()
    return grpc.metadata_call_credentials(
        IdTokenAuthMetadataPlugin(credentials, request)
    ) 
开发者ID:tensorflow,项目名称:tensorboard,代码行数:16,代码来源:auth.py

示例15: generate_credentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import metadata_call_credentials [as 别名]
def generate_credentials(cert, macaroon):
    """Create composite channel credentials using cert and macaroon metatdata"""
    # create cert credentials from the tls.cert file
    cert_creds = grpc.ssl_channel_credentials(cert)

    # build meta data credentials
    metadata_plugin = MacaroonMetadataPlugin(macaroon)
    auth_creds = grpc.metadata_call_credentials(metadata_plugin)

    # combine the cert credentials and the macaroon auth credentials
    # such that every call is properly encrypted and authenticated
    return grpc.composite_channel_credentials(cert_creds, auth_creds) 
开发者ID:adrienemery,项目名称:lnd-grpc-client,代码行数:14,代码来源:common.py


注:本文中的grpc.metadata_call_credentials方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。