Results 1 to 3 of 3

Thread: Basic Authentication

  1. #1
    Join Date
    Aug 2010
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo
    Wiki edits
    9

    Question Basic Authentication

    Hello,

    I'm using QAccessNetworkManager to download data from a URL.
    In order to provide Basic Authentication, I connect signal authenticationRequired() which is called everytime the server challenge the client.

    My applications cache username & password (even if the application exits, his password is stored and is reused) and slot for authenticationRequired() just returns the cache of username & password.
    Qt Code:
    1. void authenticationRequired (QNetworkReply * reply, QAuthenticator *authenticator) {
    2. authenticator->setUser(getCacheUsername());
    3. authenticator->setPassword(getCachePassword());
    4. }
    To copy to clipboard, switch view to plain text mode 

    Suppose that password is incorrect, then the slot always returns incorrect data and server continue to challenge client again and authenticationRequired() continue to returns incorrect credentials and the server challenge again.... that will happens for ever and application is loop !

    I think my problem is quite typical for all application which cache password of user. What is the best practice to solve this problem?

    Thank you very much

    Hai

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Basic Authentication

    Count the times the auth was incorrect and after a number of failures just re-ask the user or fail gracefully.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following 2 users say thank you to wysota for this useful post:

    frankiefrank (16th May 2011), lyhoanghai (1st September 2010)

  4. #3
    Join Date
    Dec 2010
    Location
    Israel
    Posts
    90
    Thanks
    59
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Basic Authentication

    I have a similar issue. Wysota, thanks for your solution offer.

    I use one QNetworkAccessManager for multiple download calls. I can use the signal's reply object to trace my original request, but is there any other Qt way to know that the specific reply failed authentication?

    I see both the QNetworkRequest::HttpStatusCodeAttribute and error() return 0...

Similar Threads

  1. Phonon MediaSource authentication
    By serenti in forum Qt Programming
    Replies: 0
    Last Post: 11th June 2009, 23:01
  2. mutual authentication
    By abeinoe in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2009, 06:22
  3. QtSoapHttpTransport and Proxy authentication
    By rmagro in forum Qt Programming
    Replies: 3
    Last Post: 16th December 2008, 12:07
  4. password authentication with QsslSocket
    By mate in forum Qt Programming
    Replies: 2
    Last Post: 16th July 2008, 08:17
  5. Oracle OCi w/ windows authentication
    By jgreetham in forum Qt Programming
    Replies: 1
    Last Post: 10th September 2007, 17:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.