apache / pulsar-client-python

Apache Pulsar Python client library
https://pulsar.apache.org/
Apache License 2.0
51 stars 40 forks source link

[Bug Report] OAuth doesn't work with 3.0.0 #88

Closed teonsean-dm closed 1 year ago

teonsean-dm commented 1 year ago

Using Python & OAuth.

if __name__ == "__main__":
    if len(sys.argv) != 5:
        print("Please provide message id.")
        exit(1)

    client = pulsar.Client(
        pulsar_url,
        authentication=pulsar.AuthenticationOauth2(pulsar_oauth_params),
    )
    reader = (
        client.create_reader(
            pulsar_topic,
            _pulsar.MessageId(
                int(sys.argv[3]), int(sys.argv[1]), int(sys.argv[2]),
                int(sys.argv[4])
            ),
        ),
    )[0]
    msg = reader.read_next()
    print(msg.message_id())
    print(msg.data().decode())

The same values of pulsar_url, pulsar_oauth_params and pulsar_topic works fine in 2.10.1, but fails in 3.0.0:

Traceback (most recent call last):
  File "./dm/clients/pulsar/message_reader.py", line 25, in <module>
    client.create_reader(
  File "/home/teonsean/Code/CorePython/venv/lib/python3.8/site-packages/pulsar/__init__.py", line 906, in create_reader
    c._reader = self._client.create_reader(topic, start_message_id, conf)
_pulsar.AuthenticationError: Pulsar error: AuthenticationError
BewareMyPower commented 1 year ago

I have encountered a similar error, see https://github.com/apache/pulsar-client-cpp/issues/184

I'm investigating it currently. One workaround might be building from source.

git clone git@github.com:apache/pulsar-client-python.git -b v3.1.0-candidate-1
git submodule update --init
cmake -B build
cmake --build build
cp build/lib_pulsar.so .
python3 ./setup.py bdist_wheel
sudo pip3 install dist/pulsar_client-3.1.0a1-cp38-cp38-linux_x86_64.whl --force-reinstall

The commands above are pasted from the original comment.

BewareMyPower commented 1 year ago

It should be fixed in 3.1.0. Please open another issue if you still encountered the error.