import paho.mqtt.client as mqtt

client = mqtt.Client(client_id, transport='tcp')
client.username_pw_set(username, password=passwd)

https://www.jianshu.com/p/ef546f476322