[Qgis-developer] How to change credentials using QgsCredentials and QgsNetworkAccessManager

Gino Pirelli luipir at gmail.com
Wed Jun 4 10:46:07 PDT 2014


Hi,

I'm trying to change credential after a successful login, but without
success, and I wonder it's not possible, so I ask to the community what's
I'm doing wrong.
The only way I found to login as new user is closing and opening again qgis
:|

the workflow it this one

first correct login

1) get a QgsNetworkAccessManager instance
2) prepare a request
3) auth is required by the server => QgisApp::namAuthenticationRequired is
called
4) in QgisApp::namAuthenticationRequired QgsCredential get(...) is used to
ask user and password that are set in the QAuthenticator

all proceed well... but at a moment my plugin need to be used by other
user, so next steps for a new requests are

5) get a QgsNetworkAccessManager instance
6) prepare a request
7) auth is required by the server, but QNetwarkAccessManager use cached
credentials and NO signal AuthenticationRequired => it doesn't enter
in QgisApp::namAuthenticationRequired => no credential are requested and
continue with the old credentials

QNetworkAccessManager reuse "old" QAutenticator so it is unuseful set new
credentials with QgsCredentials::instance().put(). QgsCredentials are get
only in QgisApp::namAuthenticationRequired that is called once (due the
fact that QgsNetworkAccessManager is singleton?)

next QT version (qt5) has a QNetorkAccessManager::clearAccessCache().
Method not available in QT4.

Should I use directly QNetworkAccessManager instead of then singleton
version forced by QgsNetworkAccessManager?

anyone know a way

Any help is appreciated,

Luigi Pirelli (luigi.pirelli at faunalia.it - luipir at gmail.com)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140604/30e71c24/attachment-0001.html>


More information about the Qgis-developer mailing list