Beispiel #1
0
def create_client(token, endpoint):
    channel = grpc.secure_channel(
        endpoint,
        credentials=grpc.composite_channel_credentials(
            grpc.ssl_channel_credentials(),
            grpc.access_token_call_credentials(token)))

    return graphql_pb2_grpc.GraphQLStub(channel)
Beispiel #2
0
def stub():
    credentials = grpc.access_token_call_credentials(
        token_for_api_key(sys.argv[1]))
    channel = grpc.secure_channel(
        'mainnet.eos.dfuse.io:443',
        credentials=grpc.composite_channel_credentials(
            grpc.ssl_channel_credentials(), credentials))
    return graphql_pb2_grpc.GraphQLStub(channel)
Beispiel #3
0
def client(endpoint):
    credentials = grpc.access_token_call_credentials(
        token_for_api_key(sys.argv[1]))
    channel = grpc.secure_channel(
        endpoint,
        credentials=grpc.composite_channel_credentials(
            grpc.ssl_channel_credentials(), credentials))
    return graphql_pb2_grpc.GraphQLStub(channel)
Beispiel #4
0
def create_client(endpoint):
    dfuse_api_key = os.environ.get("DFUSE_API_KEY")
    if dfuse_api_key == None:
        raise Exception(
            "you must specify a DFUSE_API_KEY environment variable")

    channel = grpc.secure_channel(
        endpoint,
        credentials=grpc.composite_channel_credentials(
            grpc.ssl_channel_credentials(),
            grpc.access_token_call_credentials(get_token(dfuse_api_key))))

    return graphql_pb2_grpc.GraphQLStub(channel)
    async def login(self):
        url = f'{self._authpoint}/v1/auth/issue'
        headers = {'Content-Type': 'application/json'}
        jsondata = {"api_key": self._api_key}

        async with aiohttp.ClientSession() as session:
            r = await session.post(url, headers=headers, json=jsondata)
            async with r:
                self._auth = await r.json()
                assert 'token' in self._auth, f'Could not auth, here is what was returned: {self._auth}, url: {url}, api_key: {self._api_key}'

        self._channel = grpc.aio.secure_channel(
            self._endpoint,
            credentials=grpc.composite_channel_credentials(
                grpc.ssl_channel_credentials(),
                grpc.access_token_call_credentials(self._auth['token'])))

        self._client = graphql_pb2_grpc.GraphQLStub(self._channel)
Beispiel #6
0
def create_client():
    channel = grpc.insecure_channel("localhost:13024", )
    return graphql_pb2_grpc.GraphQLStub(channel)