I'm writing python plugin and trying to find the right way to add PostGIS layer on the map without storing user password. After adding layer on the map, I strip out the password from uri like this:
vlayer.dataProvider().setDataSourceUri(uri.removePassword(uri.uri()))
However, when user saves the project, full connection string stays including password string.
I know that QGIS can popup user name/password dialog for me if I don't put these data on uri, but then I need to get somehow entered data, since I need to know user name and password anyway.