I am trying to connect to OPC UA with only username and password. I am using library for Python asyncua version 1.0.4

Below part snip of my code:

async with Client(url=self._url, timeout=2) as client: # client.activate_session(username="guest", password="guest") await client.set_user("guest") await client.set_password("guest") 

I have checked different option but getting still error: The user identity token is not valid.(BadIdentityTokenInvalid)

UaExpert is connecting with username and password without any problems.

Could anyone advise me what am I doing wrong?

Thank you

1 Answer

You are connecting to the server before setting the password, change your code to this:

client = Client(url=self._url, timeout=2) client.set_user("guest") client.set_password("guest") async with client : # Do your sutff 
0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.