當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。