I answer my own question because I found the solution after observing the QGis Plugin "Discovery" from Lutraconsulting. See here : https://github.com/lutraconsulting/qgis-discovery-plugin/blob/master/Discovery/dbutils.py
The code is :
""" Read PostgreSQL connection details from QSettings stored by QGIS
settings = QSettings()
settings.beginGroup(u"/PostgreSQL/connections/" + selected)
if not settings.contains("database"): # non-existent entry?
conn_info = dict()
conn_info["host"] = settings.value("host", "", type=str)
# password and username
username = ''
password = ''
authconf = settings.value('authcfg', '')
if authconf :
# password encrypted in AuthManager
auth_manager = QgsApplication.authManager()
conf = QgsAuthMethodConfig()
auth_manager.loadAuthenticationConfig(authconf, conf, True)
username = conf.config('username', '')
password = conf.config('password', '')
# basic (plain-text) settings
username = settings.value('username', '', type=str)
password = settings.value('password', '', type=str)
And as one can see they test for the two password storing possibilities and retrieve the login and password from the one that is used, after searching inside the QSettings.