Skip to content

Issue with event hub authenticate #36

@BLaurent

Description

@BLaurent

Hi, I've apply the patch from @ThisWillGoWell,
But I am stuck just after..
Here is the sample code I am using:

Exception in thread Thread-25:
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Users/laurentbenoit/.local/share/virtualenvs/result-poster-JQntJH7S/lib/python2.7/site-packages/predix/data/eventhub/grpc_manager.py", line 49, in _grpc_rx_receiver
    for m in msgs:
  File "/Users/laurentbenoit/.local/share/virtualenvs/result-poster-JQntJH7S/lib/python2.7/site-packages/grpc/_channel.py", line 351, in next
    return self._next()
  File "/Users/laurentbenoit/.local/share/virtualenvs/result-poster-JQntJH7S/lib/python2.7/site-packages/grpc/_channel.py", line 342, in _next
    raise self
_Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNKNOWN, Could not authenticate request)>
import json
import requests
import os
import fnmatch
import logging

import predix.app
from predix.data.eventhub.publisher import PublisherConfig


matches = []

for root, dirnames, filenames in os.walk('../'):
  for filename in fnmatch.filter(filenames, 'env.json'):
    matches.append(os.path.join(root, filename))


if len(matches) == 1:
  with open(matches[0], 'r') as config :
    readConfig = config.read()
    print readConfig
    jconfig = json.loads(readConfig)

    print jconfig
    target = jconfig['target']

jservices = {}
services = os.getenv('VCAP_SERVICES')
if services != None :
  jservices = json.loads(services)

jservices['predix-event-hub'] = jconfig['predix-event-hub']
jservices['predix-uaa'] = jconfig['predix-uaa']

os.environ['VCAP_SERVICES'] = json.dumps(jservices)
os.environ['PREDIX_APP_CLIENT_ID'] = jconfig['credentials']['PREDIX_APP_CLIENT_ID']
os.environ['PREDIX_APP_CLIENT_SECRET'] = jconfig['credentials']['PREDIX_APP_CLIENT_SECRET']

logging.basicConfig(level=logging.DEBUG)
app = predix.app.Manifest()
pub_config = PublisherConfig()
pub_config.publish_type = PublisherConfig.Type.SYNC

uaa = app.get_uaa()
client_id = predix.config.get_env_value(predix.app.Manifest, 'client_id')
client_secret = predix.config.get_env_value(predix.app.Manifest, 'client_secret')
if client_id and client_secret:
  logging.info("Automatically authenticated as %s" % (client_id))
  uaa.authenticate(client_id, client_secret)

print(uaa.get_scopes())


eh = app.get_eventhub(publish_config=pub_config)

count = 0
message_id = "id-" + str(count)

acks = eh.publisher.add_message(message_id, str(count)).publish_queue()
print(acks)

The service is up I am getting the health ping, and my token is ok, both sub and pub test in golang work.

Thanks in advance
Regards
B

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions