Hi everyone I am having an issue with pub sub that is driving me nuts. Basically I have a service account with admin priivs for pubsub but I can't get any thing to work and am getting the following error:
ERROR:root:AuthMetadataPluginCallback "" raised exception! Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/grpc/_plugin_wrapping.py", line 77, in call callback_state, callback)) File "/usr/local/lib/python2.7/dist-packages/google/auth/transport/grpc.py", line 77, in call callback(self._get_authorization_headers(context), None) File "/usr/local/lib/python2.7/dist-packages/google/auth/transport/grpc.py", line 61, in _get_authorization_headers self._credentials.before_request( AttributeError: 'str' object has no attribute 'before_request'
Code is super simple
from google.cloud import pubsub
credentials = '/home/airflow/Desktop/test/config/test.json'
publisher = pubsub.PublisherClient(credentials=credentials)
topic_path = publisher.topic_path("test-proj", "test")
for n in range(1, 2):
data = u'Message number {}'.format(n)
# Data must be a bytestring
data = data.encode('utf-8')
test = publisher.publish(topic_path, data=data).result()
print(test, "s")
Amy help would be really appreciated as the error message doesn't make much sense to me. Thanks